Add Email addressCollection to, cc, bcc and replytoList

Posted by san on Stack Overflow See other posts from Stack Overflow or by san
Published on 2011-07-22T06:59:46Z Indexed on 2013/06/27 16:21 UTC
Read the original article Hit count: 525

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

© Stack Overflow or respective owner

Related posts about email

Related posts about system.net.mail