strange mail problem

J

John McD

When I hardcode a MailMessage To property:
strEmailTo="(e-mail address removed)";
it successfully sends the email.

However, when I read the property from a database query
(strEmailTo =myReader["email"].ToString();) it doesn't
send the email and I don't get an error message. The
email just never arrives. I'm displaying the variable
strEmailTo on the screen, so it's definitely set
properly. Any suggestions? The code is below. TIA, John.

strEmailTo =myReader["email"].ToString();

//Email new affiliate
account is now active.\n";

MailMessage msg = new MailMessage();
msg.To = strEmailTo;
msg.From="(e-mail address removed)";
msg.From = strEmailFrom.ToString().Trim();
msg.Subject = "sdffsfdm";//strEmailSubject;
msg.Body = strEmailBody;

SmtpMail.SmtpServer="mail.megapathdsl.net";
SmtpMail.Send(msg);

lblEmailTo.Text=strEmailTo;
 
R

Rich Blum

John McD said:
When I hardcode a MailMessage To property:
strEmailTo="(e-mail address removed)";
it successfully sends the email.

However, when I read the property from a database query
(strEmailTo =myReader["email"].ToString();) it doesn't
send the email and I don't get an error message. The
email just never arrives. I'm displaying the variable
strEmailTo on the screen, so it's definitely set
properly. Any suggestions? The code is below. TIA, John.
John -

Have you tried watching the SMTP session from the PC running the
application to see what is happening? You can load the free WinPcap
driver and Analyzer program
(http://netgroup-serv.polito.it/netgroup/tools.html) and monitor TCP
port 25 traffic. You should be able to see what is being sent in the
"RCPT TO:" SMTP command, and if the remote SMTP server you specified
accepts the message for delivery. Good luck.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0471433012.html
 

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

Similar Threads


Top