while using system.net.mail to send email in asp.net, had encountered the following error:
System.ArgumentException: The parameter 'addresses' cannot be an empty string. Parameter name: addresses at System.Net.Mail.MailAddressCollection.Add(String addresses) at SendMail.btnSend_Click(Object sender, EventArgs e)
MailMessage mailMessage = new MailMessage();
mailMessage.To.Add(txtReceiver.Text);
mailMessage.CC.Add(txtCc.Text);
mailMessage.Bcc.Add(txtBcc.Text);
mailMessage.From = new MailAddress(txtSender.Text, "asdasda");
// mailMessage.From = txtSender.Text;
// mailMessage.To = txtReceiver.Text;
// mailMessage.Cc = txtCc.Text;
// mailMessage.Bcc = txtBcc.Text;
mailMessage.Subject = txtSubject.Text;
mailMessage.Body = txtBody.Text;
List<string> lststring = new List<string>();
lststring.Add(txtReceiver.Text);
lststring.Add(txtCc.Text);
lststring.Add(txtBcc.Text);
MailAddressCollection collection = new MailAddressCollection();
collection.Add(new MailAddress(txtReceiver.Text));
not sure whether it will use one address or many addresses, if required many addresses, it may required list collection, but the list collecton could not be enter to collection.Add,
therefore, tried the single address, as stated in other forum, but the error is still there
1) System.Net.Mail.MailMessag
2) System.Web.Mail.MailMessag