Following is my code. I want to send mail to multiple email address,without using foreach loop
string toEmail="123@xyz.com,456@xyz.com,789@xyz.com";
MailAddress from = new System.Net.Mail.MailAddress("myname@xyz.com");
MailAddress to = new System.Net.Mail.MailAddress(toEmail);
MailMessage mm = new MailMessage(from, to);
mm.Subject = "some subject";
mm.Body="blah! blah! blah!";
SmtpClient smtp = new SmtpClient("my-smtp-server", 25);
smtp.Send(mm);
thaqi498
Member
19 Points
62 Posts
Send email to multiple addresses
Nov 24, 2012 03:15 PM|LINK
Hello All,
Following is my code. I want to send mail to multiple email address,without using foreach loop
string toEmail="123@xyz.com,456@xyz.com,789@xyz.com"; MailAddress from = new System.Net.Mail.MailAddress("myname@xyz.com"); MailAddress to = new System.Net.Mail.MailAddress(toEmail); MailMessage mm = new MailMessage(from, to); mm.Subject = "some subject"; mm.Body="blah! blah! blah!"; SmtpClient smtp = new SmtpClient("my-smtp-server", 25); smtp.Send(mm);thanks
thaqi498
Member
19 Points
62 Posts
Re: Send email to multiple addresses
Nov 24, 2012 03:57 PM|LINK
I got the answer.
Shailendra S...
Member
551 Points
145 Posts
Re: Send email to multiple addresses
Nov 25, 2012 03:07 AM|LINK
http://forums.asp.net/t/1424727.aspx/1
www.techaray.com
Chen Yu - MS...
All-Star
21584 Points
2493 Posts
Microsoft
Re: Send email to multiple addresses
Nov 28, 2012 10:28 AM|LINK
Hi,
Glad to hear that. Would you please share your solution for us? It may help others if they meet similar issues.
Best Regards,
Feedback to us
Develop and promote your apps in Windows Store
thaqi498
Member
19 Points
62 Posts
Re: Send email to multiple addresses
Nov 28, 2012 10:37 AM|LINK
The following is my code
string emails = "user1@abc.com,user2@abc.com,helloworld@somecomapany.com"; string[] commaDel = emails.Split(new char[] { ',' }); MailMessage mm = new MailMessage(); mm.From = new MailAddress("mymailserver@somecomapny.com"); foreach (string toEmail in commaDel) { mm.To.Add(toEmail); } mm.CC.Add("test1@xyz.com"); mm.Bcc.Add("test2@xyz.com"); mm.Subject = "Some Relevant Subject"; mm.Body = "Mail Body Content" SmtpClient smtp = new SmtpClient("smtp server", 25); smtp.UseDefaultCredentials = true; smtp.Send(mm);Cheers