Problems with the SmtpMail.Send() method

  • Thread starter Thread starter Leszek
  • Start date Start date
L

Leszek

Hello,

I have created a simple code to send emails using the MailMessage class and
the SmtpMail.Send() method:

MailMessage mail = new MailMessage();
mail.From = (e-mail address removed); // hard-coded
mail.To = (e-mail address removed);
mail.Subject = "Test";
mail.Body = strMessage;
mail.BodyFormat = MailFormat.Html;
SmtpMail.Send(mail);

It works fine as long as the mail.From address is hard-coded. When I changed
the line to:
string strEmail = txtEmail.Value;
mail.From = strEmail;

txtEmail is an HTML server-control:
<input id="txtEmail" type="text" maxLength="40" size="20" name="txtEmail"
runat="server">

the code stopped working. I mean it does not send emails and even does not
throw any exception!!!
Is there any possibility to check the status of a sent message? Does
SmtpMail have any "error" property to check if the email has been sent
properly?
If I could not be sure that the message has been sent properly the
SmtpMail.Send() method would be of no use.

Please advice what to do. Should I use SmtpMail.Send() or maybe another
method?

Thanks for any hints,
Leszek Taratuta
 
Leszek,

Is txtEmail.Value the equivalent of txtEmail.Text in VB.Net?

Try using: txtEmail.Text.ToString instead.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
Some mail servers are configured to perform DNS lookup to verify the domain
name of the from e-mail address. May be this is your problem.
 
Back
Top