Saturday, March 31, 2012

SendMail

I am using SendMail to send email. I am using following code.

SmtpMail.SmtpServer = ConfigurationSettings.AppSettings["smtp_Server_Name"];
string strTo = ConfigurationSettings.AppSettings["contact_To"];
MailMessage msg = new MailMessage();

msg.To = strTo;
msg.From = txtFrom.Text;
msg.Subject = txtSubject.Text;
msg.Body = txtContent.Text;

lblStatus.Text = "Sending...";
SmtpMail.Send(msg);
lblStatus.Text = "Your Message send successfully.";

******************************************
It works great. But it sends email twice to the same address.

I am not sure why it is doing that?

Thanks
Jijo.Um, i got one suggestion and one comment here.

Suggestion:
Make sure your email is only entered once in your web config for ConfigurationSettings.AppSettings["contact_To"];

Comment:
Otherwise it's not a coding problem, as I am having a similar scenario. The code used to work, however i believe there has been changes recently to many servers in schemas against spam and viruses; Ever since those changes about a week (or two) ago the double recieving of emails have started for me, but only in the coding aspect. If i recieve emails from someone else its all fine.

What servers are you on ?

0 comments:

Post a Comment