在asp.net中发邮件,很简单,首先,需要引入System.Web.Mail,然后调用 MailMessage,简单设置即可:
Dim mMail As New MailMessage
mMail.From = "xxx@xxx.com"
mMail.To = "mxxx@xxx.com"
'mMail.cc = "抄送地址" '如果你要抄送给多个人,多个邮件地址间要用逗号分开
'mMail.bcc="密送地址"
mMail.Priority = MailPriority.Normal '邮件的优先级定义,可为普通(Normal)、高(high)、低(low)
mMail.BodyFormat = MailFormat.Text '要把邮件定义为超文本格式,t改成MailFormat.Html即可
'mMail.Attachments.Add(New MailAttachment("附件的fullname,包含路径"))
mMail.Body = "this is a mail test"
mMail.Subject = "哈哈"
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") '
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username") '登录邮箱的用户名
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password") '密码
SmtpMail.SmtpServer = "所使用的Smtp服务器地址"
SmtpMail.Send(mMail)
完了,就这么简单
Dim mMail As New MailMessage
mMail.From = "xxx@xxx.com"
mMail.To = "mxxx@xxx.com"
'mMail.cc = "抄送地址" '如果你要抄送给多个人,多个邮件地址间要用逗号分开
'mMail.bcc="密送地址"
mMail.Priority = MailPriority.Normal '邮件的优先级定义,可为普通(Normal)、高(high)、低(low)
mMail.BodyFormat = MailFormat.Text '要把邮件定义为超文本格式,t改成MailFormat.Html即可
'mMail.Attachments.Add(New MailAttachment("附件的fullname,包含路径"))
mMail.Body = "this is a mail test"
mMail.Subject = "哈哈"
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") '
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username") '登录邮箱的用户名
mMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "password") '密码
SmtpMail.SmtpServer = "所使用的Smtp服务器地址"
SmtpMail.Send(mMail)
完了,就这么简单