Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
3.00/5 (1 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.

http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx[^]

http://wiki.asp.net/page.aspx/536/send-asynchronous-mail-using-aspnet/[^]

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

Thanks
Posted
Updated 17-Nov-11 9:44am
v2
Comments
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?
Sergey Alexandrovich Kryukov 17-Nov-11 16:35pm    
How about just one address in "To:"? is the mail delivered?
--SA
moon2011 17-Nov-11 16:44pm    
Also, Not Working

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.
 
Share this answer
 
v2
Comments
moon2011 17-Nov-11 15:48pm    
can you make it more clear , please???
Nish Nishant 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.
Please use following code to send mail.
In To field you can specify comma seperated email.

C#
sendEmail("Test Subject", "me@mail.com", "user1@mail.com,user2@mail.com,user3@mail.com", "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;
try
{
 
Mail.Send(myMail);
 

return true;
}
catch (Exception ex)
{
ex.Message.ToString();
return false;
}
}
 
Share this answer
 
Comments
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900