1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
| <%@ Import Namespace="System.Web.Mail" %>
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="mail.aspx.vb" Inherits="mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub btEnvoyer_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim utilisateur, password, serveur As String
serveur = ConfigurationSettings.AppSettings("SmtpServeur")
utilisateur = ConfigurationSettings.AppSettings("SmtpUtilisateur")
password = ConfigurationSettings.AppSettings("SmtpPassword")
Dim email As New MailMessage()
email.From = tbExpediteur.Text
email.To = tbDestinataire.Text
email.Subject = tbObjet.Text
email.Body = tbMessage.Text
email.Priority = MailPriority.High
SmtpMail.SmtpServer = serveur
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", utilisateur)
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password)
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", serveur)
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25")
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2")
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
Try
SmtpMail.Send(email)
recu.Text = "Mail Envoyé"
Catch ex As Exception
lblErreur.Text = ex.Message
End Try
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Page sans titre</title>
<style type="text/css">
.style1
{
text-align: center;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<style type="text/css">
.style1
{
text-align: center;
}
#form1
{
text-align: center;
}
</style>
</head>
<body>
<div>
</div>
<div class="style1">
<asp:Label ID="Label1" runat="server" Text="expéditeur"></asp:Label>
<asp:TextBox ID="tbExpediteur" runat="server"></asp:TextBox>
</div>
<p class="style1">
<asp:Label ID="Label2" runat="server" Text="Destinataire"></asp:Label>
<asp:TextBox ID="tbDestinataire" runat="server" ></asp:TextBox>
</p>
<p style="text-align: center">
<asp:TextBox ID="tbObjet" runat="server" ></asp:TextBox>
<asp:Label ID="lblErreur" runat="server"></asp:Label>
</p>
<p style="text-align: center">
<asp:TextBox ID="tbMessage" runat="server" Height="141px" TextMode="MultiLine"
Width="350px" ></asp:TextBox>
</p>
<p style="text-align: center">
<asp:Button ID="btEnvoyer" runat="server" Text="Envoi"
onclick="btEnvoyer_Click" />
</p>
<asp:Label ID="recu" runat="server" style="text-align: center"></asp:Label>
</form>
</body>
</html> |