Answered by:
the Parameter 'address' cannot be an empty string

Question
-
try
{
MailMessage message = new MailMessage();message.To.Add(
"willthiswork89@msn.com");message.From =
new MailAddress(textBox1.Text);message.Subject =
"BUG REPORT"; if (radioButton1.Checked == true){
message.Body = textBox2.Text;
}
if (statusf == "nono"){
message.Body = statusf +
"\n\n\n" + textBox3.Text;}
if (statusf == "noyes"){
message.Body = statusf +
"\n\n\n" + textBox3.Text;}
SmtpClient client = new SmtpClient("smtp-server.neo.rr.com");client.Send(message);
}
catch (Exception ex){
MessageBox.Show(ex.Message.ToString());}
i cant figure out what that error message means? its saying the address cannot be an empty string? any help would be appreciated
Monday, May 14, 2007 7:41 PM
Answers
-
message.From = new MailAddress(textBox1.Text);
The "From" is not a new MailAddress
It's looking for the from address for the existing mailmessage not a new one.
so:
message.From = textBox1.Text;
Adamus
Monday, May 14, 2007 7:50 PM
All replies
-
message.From = new MailAddress(textBox1.Text);
The "From" is not a new MailAddress
It's looking for the from address for the existing mailmessage not a new one.
so:
message.From = textBox1.Text;
Adamus
Monday, May 14, 2007 7:50 PM -
mailMessage.From = email.Text;
throws error:
Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress' C:\Prace\webroot\BioNea\BioNea\Controls\ContactForm.ascx.cs
Sunday, June 29, 2008 3:27 PM -
Kostkac said:
mailMessage.From = email.Text;
throws error:
Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress' C:\Prace\webroot\BioNea\BioNea\Controls\ContactForm.ascx.cs
> message.From = new MailAddress(textBox1.Text);
Where is the message.To address? Coult it be the problem? It is an empty string in your setup.
This is how the mailAddress is formed:
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system/html/0cf13cb2-2b5d-f182-dc78-92203db78e74.htm
MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
MailAddress to = new MailAddress("jane@contoso.com", "Jane Clayton");
AlexBSunday, June 29, 2008 4:54 PM -
Adamus Turner said:
message.From = textBox1.Text;
Adamus
This is how the mailAddress is formed:
ms-help://MS.VSCC.v90/MS.MSDNQTR.v90.en/fxref_system/html/0cf13cb2-2b5d-f182-dc78-92203db78e74.htm
MailAddress from = new MailAddress("ben@contoso.com", "Ben Miller");
MailAddress to = new MailAddress("jane@contoso.com", "Jane Clayton");
AlexB- Proposed as answer by Equus Asinus Friday, June 5, 2009 1:08 PM
Sunday, June 29, 2008 4:56 PM -
message.From = new MailAddress(textBox1.Text);
you will get this exception if textBox1.Text is String.EmptyFriday, June 5, 2009 1:12 PM -
Hello,
I have a similar problem when I had the "To" to a specific address when I do it again, it sends me the email to the new address and to the first one. Is there a way to reset or empty the "To" so this stops happening?
Thanks
Wednesday, December 26, 2018 1:50 PM