使用.net的SmtpMail发送邮件及本机SMTP的简单配置
2004-12-06 22:18
841 查看
这是我在这里发的第一篇文章
这几天,我做了一个有关发邮件的程序,也查了不少资料,下面把主要部分总结一下。
首先,当然是配置本机SMTP服务拉,如果是采用非本机的SMTP服务则不用做这一步(废话)。先打开Internet信息服务,右击 SMTP虚拟服务器--属性--访问--中继--添加,然后输入你的ip就可以了(当然如果为了方便你也可以输入127.0.0.1),确定,配置完成。
然后编写代码:(我的代码如下,采用VB.net编写)
先要导入System.Web.Mail命名空间
Imports System.Web.Mail
1.采用本机SMTP服务器
Dim newMail As MailMessage = New MailMessage
With newMail
.BodyFormat = MailFormat.Html
.From = "发送人邮件地址"
.To = "接受人邮件地址"
.Subject = "test"
.Body = "test"
End With
SmtpMail.SmtpServer = "本机的ip" '要和你刚才配置的ip一样
SmtpMail.Send(newMail)
2.采用其它机器SMTP服务器(以163为例)
Dim newMail As MailMessage = New MailMessage
With newMail
.BodyFormat = MailFormat.Html
.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","你所要使用的SMTP的账号")
.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "你的账号密码")
.From = "发送人邮件地址"
.To = "接受人邮件地址"
.Subject = "test"
.Body = "test"
End With
SmtpMail.SmtpServer = "smtp.163.com" '163的SMTP服务器地址
SmtpMail.Send(newMail)
如果需要其他详细信息的可以参考http://www.systemwebmail.com/
这几天,我做了一个有关发邮件的程序,也查了不少资料,下面把主要部分总结一下。
首先,当然是配置本机SMTP服务拉,如果是采用非本机的SMTP服务则不用做这一步(废话)。先打开Internet信息服务,右击 SMTP虚拟服务器--属性--访问--中继--添加,然后输入你的ip就可以了(当然如果为了方便你也可以输入127.0.0.1),确定,配置完成。
然后编写代码:(我的代码如下,采用VB.net编写)
先要导入System.Web.Mail命名空间
Imports System.Web.Mail
1.采用本机SMTP服务器
Dim newMail As MailMessage = New MailMessage
With newMail
.BodyFormat = MailFormat.Html
.From = "发送人邮件地址"
.To = "接受人邮件地址"
.Subject = "test"
.Body = "test"
End With
SmtpMail.SmtpServer = "本机的ip" '要和你刚才配置的ip一样
SmtpMail.Send(newMail)
2.采用其它机器SMTP服务器(以163为例)
Dim newMail As MailMessage = New MailMessage
With newMail
.BodyFormat = MailFormat.Html
.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1")
.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername","你所要使用的SMTP的账号")
.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "你的账号密码")
.From = "发送人邮件地址"
.To = "接受人邮件地址"
.Subject = "test"
.Body = "test"
End With
SmtpMail.SmtpServer = "smtp.163.com" '163的SMTP服务器地址
SmtpMail.Send(newMail)
如果需要其他详细信息的可以参考http://www.systemwebmail.com/
相关文章推荐
- jbpm3与发散模型
- jBPM的令牌/信令技术
- jBPM的type问题,big bug!
- rhas3.0 + qmail + mysql + smtp + vpopmail + igenus + qmailadmin
- PMD
- Review of Debugging the development process 7. It's All About Attitude
- jBPM工作流程定义
- Review of Debugging the development process 6. Constant, Unceasing Improvement
- Review of Debugging the development process 5. Schedule Madness
- 快速部署Jboss jBpm2.0运行环境
- The Game API package provides a series of classes that enable the development of rich gaming content for wireless devices.
- JBOSS jBPM 工作流管理系统简介
- 数据建模工具与BPM日趋融合
- Review of Debugging the development process 4. Unbridled Enthusiasm
- Review of Debugging the development process 3. Of Strategic Importance
- Review of Debugging the development process 1. Laying The Groundwork
- 一个JBPM工作流管理示例(四)
- JBPM工作流引擎理论基础
- Lippman:我对中国程序员的忠告
- Three Philosophies in Development and Design