how to send mail to selected values in checkboxlist

Posted by Parthibansk under ASP.NET on 6/26/2013 | Points: 10 | Views : 2077 | Status : [Member] | Replies : 3
got a scenario to send mail to all newsletter subscribers in a portal..when i select all items in checkboxlist, only 1st item selected is getting mail..

selected.value is selecting only one item in checkboxlist..

below is my code...

string message = "";

for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
message += CheckBoxList1.Items[i].Value + "; ";
}


MailMessage Msg = new MailMessage();
MailAddress fromMail = new MailAddress("PARTHIBAN@xyz.com");
// Sender e-mail address.
Msg.From = fromMail;
// Recipient e-mail address.
Msg.To.Add( CheckBoxList1.SelectedValue);




Responses

Posted by: Geniusvishal on: 6/26/2013 [Member] Starter | Points: 25

Up
0
Down
Modify this line:

Msg.To.Add( CheckBoxList1.SelectedValue);

to

Msg.To.Add( message);

Thanks and Regards,
Vishal Ranjan,Software Developer
http://www.dotnetvishal.com

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Parthibansk on: 6/26/2013 [Member] Starter | Points: 25

Up
0
Down
modified but got error:

System.FormatException: The specified string is not in the form required for an e-mail address.

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Geniusvishal on: 6/26/2013 [Member] Starter | Points: 25

Up
0
Down
http://imar.spaanjaars.com/499/how-to-handle-the-error-the-specified-string-is-not-in-the-form-required-for-an-e-mail-address

Thanks and Regards,
Vishal Ranjan,Software Developer
http://www.dotnetvishal.com

Parthibansk, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response