将电子邮件地址集合添加到、抄送、密件抄送和回复列表中
我想将 MailAddressCollection 添加到我的 MailMessage(Net.Mail) 的 to、cc、bcc 和replytolist
我的代码就像
MessageEntity.To.Add(GetMailAddress(TOEmailAddress));
MessageEntity.CC.Add(GetMailAddress(CCEmailAddress));
MessageEntity.Bcc.Add(GetMailAddress(BCCEmailAddress));
MessageEntity.RepltToList.Add(GetMailAddress(ReplyEmailAddress));
private static MailAddressCollection GetMailAddress(List<string> LstMailAddress)
{
MailAddressCollection MAddressCollection = new MailAddressCollection();
if (MailAddress != null)
{
foreach (string EmailAddress in MailAddress)
{
if (IsValidEmailId(EmailAddress))
{
MAddressCollection.Add((new MailAddress(EmailAddress)));
}
}
}
return MAddressCollection;
}
它显示错误无法从“System.Net.Mail.MailAddressCollection”转换为“string”
是否可以添加EmailAddressCollection 发送电子邮件至/cc/bcc/ReplyToList?
谢谢 桑
i want to add MailAddressCollection with to,cc,bcc and replytolist of my MailMessage(Net.Mail)
my code Like
MessageEntity.To.Add(GetMailAddress(TOEmailAddress));
MessageEntity.CC.Add(GetMailAddress(CCEmailAddress));
MessageEntity.Bcc.Add(GetMailAddress(BCCEmailAddress));
MessageEntity.RepltToList.Add(GetMailAddress(ReplyEmailAddress));
private static MailAddressCollection GetMailAddress(List<string> LstMailAddress)
{
MailAddressCollection MAddressCollection = new MailAddressCollection();
if (MailAddress != null)
{
foreach (string EmailAddress in MailAddress)
{
if (IsValidEmailId(EmailAddress))
{
MAddressCollection.Add((new MailAddress(EmailAddress)));
}
}
}
return MAddressCollection;
}
It is showing the error cannot convert from 'System.Net.Mail.MailAddressCollection' to 'string'
Is it possible to add the EmailAddressCollection to email's to/cc/bcc/ReplyToList?
Thanks
San
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
通过快速重构,您可以这样做:
With a quick refactor, you can do it like this: