Click here to Skip to main content
13,201,050 members (55,167 online)
Rate this:
Please Sign up or sign in to vote.
See more:
hi all

i have acontactUs page which in it the user will enter some data and that data will be delivered to many mails.
i tried more than one code but after uploading thecode on my server , the mail doesn't reach any recivers mail.[^][^]

So, Any Help ,Please???????

Posted 17-Nov-11 9:36am
Updated 17-Nov-11 9:44am
DaveAuld 17-Nov-11 15:44pm
Edit: Links Fixed.
DaveAuld 17-Nov-11 15:46pm
Have you taken the code for example from the first link and implemented it, and tried to send email to a SINGLE email address? Have you debugged and stepped through the code and caught any exceptions? My guess, is a SMTP authentication issue and you are problem getting a SMTP relay error. What code are you currently using?
SAKryukov 17-Nov-11 16:35pm
How about just one address in "To:"? is the mail delivered?
moon2011 17-Nov-11 16:44pm
Also, Not Working
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Most probable cause is that your mail server settings are either not correct or your mail server does not relay email. Try to send an email using a regular email client with your mail server and see if the emails are delivered.
moon2011 17-Nov-11 15:48pm
can you make it more clear , please???
Nishant Sivakumar 17-Nov-11 15:49pm
Use a free email client, set it up to use your mail server, and try to send a few emails out. This will tell you if the problem is with your mail server/config.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Please use following code to send mail.
In To field you can specify comma seperated email.

sendEmail("Test Subject", "", ",,", "Body of email", "", "",null);
public static bool sendEmail(string strSubject, string strFrom, string strTo, string strBody, string strCc, string strBcc,string displayName)
System.Net.Mail.SmtpClient Mail = new System.Net.Mail.SmtpClient();
Mail.Host = clsCommon.value("SMTPServer").ToString();
string username = null;
string Password = null;
Mail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
username = "MailUserName";
Password = "MailPassword";
System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential(username, Password);
Mail.UseDefaultCredentials = false;
Mail.Credentials = basicAuthenticationInfo;

System.Net.Mail.MailMessage myMail = new System.Net.Mail.MailMessage();
myMail.Subject = strSubject;
myMail.From = new System.Net.Mail.MailAddress(strFrom,displayName);
myMail.To.Add(new System.Net.Mail.MailAddress(strTo));
if (!string.IsNullOrEmpty(strCc))
myMail.CC.Add(new System.Net.Mail.MailAddress(strCc));
if (!string.IsNullOrEmpty(strBcc))
myMail.Bcc.Add(new System.Net.Mail.MailAddress(strBcc));
myMail.IsBodyHtml = true;
myMail.Body = strBody;
return true;
catch (Exception ex)
return false;
moon2011 18-Nov-11 8:24am
Thanks alot for your reply , but i have a question:
clsCommon ???????
can i know what is that class??
Mukund Thakker 18-Nov-11 10:56am
You can replace clsCommon with web.config SMTPServer value or
Mail.Host = "Hostname";

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171020.1 | Last Updated 18 Nov 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100