Click here to Skip to main content
Rate this: bad
good
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.
 
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 17-Nov-11 10:36am
moon20111.1K
Edited 17-Nov-11 10:44am
DaveAuld177.7K
v2
Comments
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?
--SA
moon2011 at 17-Nov-11 16:44pm
   
Also, Not Working
Rate this: bad
good
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.
  Permalink  
v2
Comments
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
good
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", "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;
}
}
 
  Permalink  
Comments
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 OriginalGriff 8,284
1 Sergey Alexandrovich Kryukov 7,327
2 DamithSL 5,614
3 Manas Bhardwaj 4,986
4 Maciej Los 4,920


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 18 Nov 2011
Copyright © CodeProject, 1999-2014
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