[学习日记]记录听棠兄的EAMIL发送方法,改成vb.net可用

imports system.web.mail
当然,在VS.net平台里用vb.net开发时,这个命名空间是不能直接用的,得先在引用中引用上system.web.dll

主要发送代码如下
Dim mail As MailMessage = New MailMessage
            mail.
To = "heqiang01@163.com,aowind@163.com"
            mail.From = "aowind@163.com"
            mail.Subject = "this is a test email."
            mail.Body = "<b>Some text goes here</b> "
            mail.BodyFormat = MailFormat.Html '设置为HTML格式 
            mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate""1"'设置为需要用户验证 

            mail.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendusername""aowind"'设置验证用户名 

            mail.Fields.Add(
"http://schemas.microsoft.com/cdo/configuration/sendpassword""xxxxxx"'设置验证密码 

            SmtpMail.SmtpServer 
= "smtp.163.com" '邮件服务器地址 
            SmtpMail.Send(mail)
当然密码是不能写出来了,嘿嘿!
在mail.to这里所赋的值是收信人的地址,可以写多个,用","分隔就行了。
关键在于是需要身份验证的,所以红底这里几句就是实现身份验证的代码,感谢听棠兄。
当然自己架设的mail服务器,不用验证的话,就可以不用这几行了。
posted @ 2005-03-04 10:37  Aowind  阅读(620)  评论(0编辑  收藏  举报