MailBee.NET Objects发送电子邮件(SMTP)教程八:使用多个SMTP服务器发送邮件

C#:

SmtpServer smtp_srv = new SmtpServer();

smtp_srv.Name = “mail.domain.com”;
smtp_srv.AccountName = “john_doe”;
smtp_srv.Password = “secret”;

oMailer.SmtpServers.Add(smtp_srv);

VB.NET:
Dim smtp_srv As SmtpServer =  New SmtpServer() 
 
smtp_srv.Name = “mail.domain.com”
smtp_srv.AccountName = “john_doe”
smtp_srv.Password = “secret”
 
oMailer.SmtpServers.Add(smtp_srv)

 SMTP.SmtpServers.Add方法的下一次重载允许通过指定的服务器名称或相应的IP地址添加新的SMTP服务器,如下所示:

C#:

oMailer.SmtpServers.Add(“127.0.0.1”);
oMailer.SmtpServers.Add(“smtp.company.com”);

VB.NET:
oMailer.SmtpServers.Add(“127.0.0.1”)
oMailer.SmtpServers.Add(“smtp.company.com”)

 此外,开发人员可以指定SMTP服务器的端口 和优先级。默认优先级为0(即最高),默认端口 为25。以下代码将两个具有不同优先级的SMTP服务器添加到集合中:

C#:

oMailer.SmtpServers.Add(“127.0.0.1”, 33, 1);
oMailer.SmtpServers.Add(“smtp.company.com”, 37, 2);

VB.NET:
oMailer.SmtpServers.Add(“127.0.0.1”, 33, 1)
oMailer.SmtpServers.Add(“smtp.company.com”, 37, 2)

此外,SMTP.SmtpServers.Add方法的以下重载允许通过指定的服务器名称(或相应的IP地址)、登录名和密码将SMTP服务器添加到集合中,如下所示:

C#:

oMailer.SmtpServers.Add(“127.0.0.1”, “dan_brown”, “password”);
oMailer.SmtpServers.Add(“smtp.company.com “, “john_doe”, “secret”);

VB.NET:
oMailer.SmtpServers.Add(“127.0.0.1”, “dan_brown”, “password”)
oMailer.SmtpServers.Add(“smtp.company.com “, “john_doe”, “secret”)

 以上就是本次教程的全部内容,接下来会有更多相关教程,敬请关注!您也可以在评论者留下你的经验和建议。


试用、下载、了解更多产品信息请点击“咨询在线客服”   

MailBee.NET Objects发送电子邮件(SMTP)教程八:使用多个SMTP服务器发送邮件

标签:电子邮件

声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!

上一篇 2017年5月3日
下一篇 2017年5月4日

相关推荐

发表回复

登录后才能评论