发送邮件到通讯组列表 [英] Sending mail to distribution list

查看:93
本文介绍了发送邮件到通讯组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在开发一个Web应用程序,在其中我需要向一组用户发送邮件.他们的电子邮件ID保存在名为MyList的组中.以下代码用于发送邮件.

Hi all,

I am developing a web application, in which i need to send mail to a group of users. Their email ids are saved in a group called MyList. The following code is used to send the mail.

MailMessage mail = new MailMessage();
               
                mail.From = new MailAddress(strSenderEmail);
                //mail.To.Add(new MailAddress(strToEmail));
                mail.To.Add(new MailAddress(MyList));
                mail.Subject = strSubject;
                mail.IsBodyHtml = true;
                AlternateView htmlView = AlternateView.CreateAlternateViewFromString(strBody, null, "text/html");
                htmlView.LinkedResources.Add(logo1);
                htmlView.LinkedResources.Add(logo2);
                mail.AlternateViews.Add(htmlView);
                SmtpClient smtp = new SmtpClient(strMailServer);
                smtp.Send(mail);



但我在''mail.To.Add(new MailAddress(MyList));''
遇到错误 说电子邮件地址格式不正确.

我如何将邮件发送到名为"MyList"的列表.我该如何解决?

在此先感谢
Sruthi R



But i am getting error at ''mail.To.Add(new MailAddress(MyList));''
saying the email address is not in the correct format.

How can i send a mail to the list called ''MyList''. How can i solve this?

Thanks in advance
Sruthi R

推荐答案

MailAddress是单个项目,而不是值列表.您将必须为列表中的每个项目创建一个新的MailAddress.

顺便说一句:您可能希望查看抄送或密件抄送属性,而不是收件人-最后一个属性在发送时不会列出所有内容,因此组中的成员不会每次都获得对方的电子邮件地址.
A MailAddress is a single item, not a list of values. You will have to create a new MailAddress for each item in the list.

BTW: You might want to look at the Cc or Bcc property rather than To - the last one doesn''t list them all when it sends it so members of your group don''t get each others email address each time.


这篇关于发送邮件到通讯组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆