Problems with the SmtpMail.Send() method

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
 
S

S. Justin Gengo

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
 
S

Sherif ElMetainy

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top