SmtpMail.SmtpServer 属性属性值 电子邮件中继服务器的名称。如果没有设置 SmtpServer,则使用本地 SMTP 服务器的名称。备注如果本地 SMTP 服务器(包括在 Windows 2000 和 Windows Server 2003 中)位于阻塞任何直接 SMTP 通信量(通过端口 25)的防火墙之后,则需要查找网络上是否有可用的智能主机能用来中转发往 Internet 的 SMTP 消息。智能主机是一个 SMTP 服务器,它能够中转从内部 SMTP 服务器直接发送到 Internet 的外出电子邮件。智能主机应能同时连接到内部网络和 Internet,以用作电子邮件网关。有关配置本地 SMTP 服务器方面的信息,请参见 MSDN Library 中的文章“Manage Your Company's E-mail with the Windows 2000 SMTP Service”和“Using SMTP for Outgoing Messages”,网址为 http://msdn.microsoft.com。 示例 [Visual Basic] ' This example assigns the name of the mail relay server on the ' local network to the SmtpServer property. SmtpMail.SmtpServer = "RelayServer.Contoso.com"[C#] //This example assigns the name of the mail relay server on the //local network to the SmtpServer property. SmtpMail.SmtpServer = "RelayServer.Contoso.com";
SmtpMail.SmtpServer 用的是IIS默认的SMTP,如果想指定其他SMTP,用C#的这个是不能实现的,他不能设置用户名密码。//可以,用 em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //set your username here em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //set your password here 具体 http://blog.csdn.net/zhzuo/archive/2004/07/12/39459.aspx
电子邮件中继服务器的名称。如果没有设置 SmtpServer,则使用本地 SMTP 服务器的名称。备注如果本地 SMTP 服务器(包括在 Windows 2000 和 Windows Server 2003 中)位于阻塞任何直接 SMTP 通信量(通过端口 25)的防火墙之后,则需要查找网络上是否有可用的智能主机能用来中转发往 Internet 的 SMTP 消息。智能主机是一个 SMTP 服务器,它能够中转从内部 SMTP 服务器直接发送到 Internet 的外出电子邮件。智能主机应能同时连接到内部网络和 Internet,以用作电子邮件网关。有关配置本地 SMTP 服务器方面的信息,请参见 MSDN Library 中的文章“Manage Your Company's E-mail with the Windows 2000 SMTP Service”和“Using SMTP for Outgoing Messages”,网址为 http://msdn.microsoft.com。
示例
[Visual Basic]
' This example assigns the name of the mail relay server on the
' local network to the SmtpServer property.
SmtpMail.SmtpServer = "RelayServer.Contoso.com"[C#]
//This example assigns the name of the mail relay server on the
//local network to the SmtpServer property.
SmtpMail.SmtpServer = "RelayServer.Contoso.com";
em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", this.UserName); //set your username here
em.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", this.Password); //set your password here
具体
http://blog.csdn.net/zhzuo/archive/2004/07/12/39459.aspx