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
| Dim email As New MailMessage()
Dim utilisateur, password, serveur As String
utilisateur = ConfigurationSettings.AppSettings("SmtpUtilisateur")
password = ConfigurationSettings.AppSettings("SmtpPassword")
serveur = ConfigurationSettings.AppSettings("SmtpServeur")
email.From = "me@toto.fr"
email.To = "lui@toto.fr"
email.Subject = "Un mail avec une image"
email.BodyFormat = MailFormat.Html
email.Body = "<html>" & _
"<head>" & _
"<meta http-equiv=""Content-Language"" content=""fr"">" & _
"<metahttp-equiv=""Content-Type""content=""text/html;charset=windows-1252"">"&_ "</head>" & _
"<body>" & _
"<p>Mon premier mail au format HTML</p>" & _
"<img src="images/editor/removeformat.gif" width="21" height="20" alt="Retirer la mise en forme du texte" />&_
"</body>" & _
"</html>"
SmtpMail.SmtpServer = serveur email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", utilisateur)
email.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", password)
Try SmtpMail.Send(email)
Catch ex As Exception
lblErreur.Text = ex.Message
End Try |
Partager