首页 新闻 搜索 专区 学院

有木有人会写循环讲一封邮件发给不同的邮件地址

0
[已解决问题] 解决于 2011-11-04 16:05

MailMessage mailMessage = new MailMessage();
mailMessage.From = this._from;

if (isBulkprintDate == true || isDeliveryDate == true || isCreateWorkOrderInfo == true)
{
mailMessage.To = "emilypei@toppanleefung.com";
}
if (isBulkprintDate == true || isDeliveryDate == true)
{
if (location == "H")
{
mailMessage.To = "elevenzeng@toppanleefung.com";
}
else if (location =="S")
{
mailMessage.To = "emilypei@toppanleefung.com";
}
}
if (isBulkprintDate == true)
{
if (teamA == true || teamB == true)
{
//mailMessage.To = "sz-ttn@toppanleefung.com";
mailMessage.To = "emilypei@toppanleefung.com";
}
else if (teamC == true)
{
//mailMessage.To = "vite-hkttn@toppanleefung.com";
mailMessage.To = "emilypei@toppanleefung.com";
}
}
mailMessage.Cc = this._cc;
mailMessage.Subject = "[Job Name] – Change in Bulk Print Date/Delivery Date ";

mailMessage.Body = mailBody.ToString().Replace("{workOrderID}", workOrderID).Replace("{companyName}", companyName).Replace("{jobName}", jobName).Replace("{jobFounction}", jobFounction).Replace("{bulkPrintDate}", bulkPrintDate).Replace("{deliveryDate}", deliveryDate).Replace("{sales}", sales).Replace("{updateBy}", updateBy).Replace("{updateDate}", updateDate);
mailMessage.BodyFormat = MailFormat.Html;

SmtpMail.SmtpServer = this._smtp_server;
SmtpMail.Send(mailMessage);
return true;

 

怎么讲这段代码循环 发送

Emilyer的主页 Emilyer | 初学一级 | 园豆:171
提问于:2011-11-04 10:48
< >
分享
最佳答案
0

用一个数组来存放所以收件人的address.

然后循环该数组取address。如果还有其它条件,可以这样:

Dictioary<key, address list>  :key可以用来特定群组。address list即该群组所有email address

Repository | 小虾三级 |园豆:610 | 2011-11-04 11:19

我的地址是通过判断的出来的不知道怎么写   高人帮忙我那个代码写写  写写

Emilyer | 园豆:171 (初学一级) | 2011-11-04 11:27

@Emliy.pei:

用这个,Dictioary<key, address list>  :key可以用来特定群组。address list即该群组所有email address

你先归好类。比如: 

if (location == "H")
{
mailMessage.To = "elevenzeng@toppanleefung.com";
}

对应:

key: H

address: "elevenzeng@toppanleefung.com"

Repository | 园豆:610 (小虾三级) | 2011-11-04 11:31

@Repository: 这个可以键值对  其他的几个值似乎不可以哦。。

Emilyer | 园豆:171 (初学一级) | 2011-11-04 11:39

@Emliy.pei:

写程序讲究变通。其它几个也可以这样处理。

Repository | 园豆:610 (小虾三级) | 2011-11-04 11:54

@Repository: 除了这个能有其他方法吗  

Emilyer | 园豆:171 (初学一级) | 2011-11-04 12:06

@Emliy.pei: 在求助    应该会有更加简便的方法

Emilyer | 园豆:171 (初学一级) | 2011-11-04 12:08
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册