Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
1.89/5 (2 votes)
See more:
Hello,

I want to send mail from my website domain(www.sample.com)
I have written below code. It is not returning any error. But it is not sending mail once I uploaded the pages in the server. Once click on email send, it is not getting any error, but not receiving the mail.
C#
System.Net.Mail.SmtpClient smtpClient = new System.Net.Mail.SmtpClient("mail.sample.co.uk", 25);

           smtpClient.Credentials = new System.Net.NetworkCredential("smtpuser@sample.co.uk", "pass@123");
           smtpClient.UseDefaultCredentials = true;
           smtpClient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
           smtpClient.EnableSsl = false;
           System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

           //Setting From , To and CC
           mail.From = new System.Net.Mail.MailAddress("smtpuser@sample.co.uk", "MyWeb Site");
           mail.To.Add(new System.Net.Mail.MailAddress("myemail@gmail.com"));
           mail.CC.Add(new System.Net.Mail.MailAddress("myemail1@gmail.com"));

           smtpClient.Send(mail);
           Response.Write("mail send!!!!!!!");

I am getting the "mailsend" response text in the page once calling the sending method.

Please help
Anjana
Posted
Updated 13-Jan-15 5:42am
v2
Comments
Sergey Alexandrovich Kryukov 13-Jan-15 11:41am    
Sending mail is one thing, receiving it is something different. Who knows why it's not delivered? Check up everything, try to do exactly the same with the same addresses and credential using some existing mail client, and so on.
—SA
DamithSL 13-Jan-15 11:48am    
try with smtpClient.UseDefaultCredentials = false;

Try this: Sending an Email in C# with or without attachments: generic routine.[^] - I know it works!

So if it doesn't for you, then you need to look at your username / password combination for starters.
 
Share this answer
 
Please check your junk folder. Sometimes email sits in Junk/Spam folder. Check below link

Smtp mail throuws an error[^]
 
Share this answer
 

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