我想将 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”转换为“字符串”
是否可以将 EmailAddressCollection 添加到电子邮件的 to/cc/bcc/ReplyToList?
谢谢桑