Sending mail using SmtpClient in .net
Posted
by Manish Gupta
on Stack Overflow
See other posts from Stack Overflow
or by Manish Gupta
Published on 2010-03-18T14:40:34Z
Indexed on
2010/03/18
14:41 UTC
Read the original article
Hit count: 746
I am unable to send the mail using smtp client. here is the code:
SmtpClient client=new SmtpClient("Host"); client.Credentials=new NetworkCredential("username", "password"); MailMessage mailMessage = new MailMessage(); mailMessage.from="[email protected]"; mailMessage.To.Add("[email protected]"); mailMessage.body="body"; mailMessage.subject="subject"; client.Send(mailMessage);
The problem is that when I use this code in ASP.NET application, I do not recieve any mails. When in asp.net I change the from mail address to username given in NetworkCredential, I recieve mails.
But in C# windows application, I can get emails, even if sender's email address is not valid.
Thanks in advance....
© Stack Overflow or respective owner