Click here to Skip to main content
11,812,712 members (72,103 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET
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
Edited 17-Nov-11 9:44am
DaveAuld at 17-Nov-11 15:44pm
Edit: Links Fixed.
DaveAuld at 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 at 17-Nov-11 16:35pm
How about just one address in "To:"? is the mail delivered?
moon2011 at 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 at 17-Nov-11 15:48pm
can you make it more clear , please???
Nishant Sivakumar at 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 at 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 at 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
0 KrunalRohit 184
1 CHill60 180
2 Abhinav S 175
3 Palash Mondal_ 160
4 RyanDev 130
0 OriginalGriff 3,893
1 KrunalRohit 2,441
2 CPallini 2,240
3 Maciej Los 2,155
4 ppolymorphe 1,725

Advertise | Privacy | Mobile
Web04 | 2.8.151002.1 | Last Updated 18 Nov 2011
Copyright © CodeProject, 1999-2015
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