Imports System.Text
'**********************************
'Send mail example using Web.Mail *
'email:wgscd@126.com qq:153964481 *
'**********************************
'notice first you should add a reference:Web.Mail.dll
'and you can send mail throught Socket .
'there's a Socket example in my Blog
Private Sub ButtonSendMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mail As Web.Mail.SmtpMail
Dim mm As New Web.Mail.MailMessage
Dim ma As New Web.Mail.MailAttachment("c:/wgscd.htm", Web.Mail.MailEncoding.Base64)
mail.SmtpServer = "smtp.126.com"
mm.Attachments.Add(ma)
mm.BodyEncoding = Encoding.Default
mm.BodyFormat = Web.Mail.MailFormat.Html
mm.From = "wgscd@126.com"
mm.To = "wgscd@126.com"
mm.Bcc = "wgscd@126.com"
mm.Cc = "wgscd@126.com;wgscd2002@126.com"
'设置为需要用户验证
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
'设置验证用户名(把my_username_here改为你的验证用户名)
mail.Fields.Add(http://schemas.microsoft.com/cdo/configuration/sendusername, "my_username_here")
'设置验证密码(把password改为你的验证密码)
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password")
mm.Body = "hello my firend !"
mail.Send(mm)
' mail.Send("wgscd@126.com", "wgscd2002@126.com", "hello", "content")'this also can send mail.
End Sub