Click here to Skip to main content
15,911,474 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team,

I want to create email sending application where i need to setup from email as any email and receiver email also any email. It means From email could be gmail,yahoo, @otherexample.com.

Do we have any provision in c# that we can send email to anyone.

Please suggest.

Thanks.
Posted

1 solution

using System.Net.Mail;

...

MailMessage mail = new MailMessage("you@yourcompany.com", "user@hotmail.com");
SmtpClient client = new SmtpClient();
client.Port = 25;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
client.Host = "smtp.google.com";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
client.Send(mail);
 
Share this answer
 
Comments
Member 8090436 5-Nov-15 0:33am    
Not working have tried.
Please suggest alternate approach.
Gyaneswar kumar 5-Nov-15 0:40am    
what you'are asking that should something like configurable or other coding approach?
This is final code to send email via c#..

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