Click here to Skip to main content
15,898,939 members
Please Sign up or sign in to vote.
3.33/5 (2 votes)
See more:
How to Send Email from C# Window Application?
Any Reference?
Please Help me..
Posted

Try this
MailMessage m = new MailMessage("mailidofSender", To);
           m.Subject = Subject;
           m.Body = Body;
           m.IsBodyHtml = true;
           SmtpClient smtp = new SmtpClient();
           smtp.Host = "mail.google.com";
           NetworkCredential authinfo = new NetworkCredential("mailidfrom", "YourPassword");
           smtp.UseDefaultCredentials = false;
           smtp.Credentials = authinfo;
           smtp.Send(m);
 
Share this answer
 
Comments
Member 11525788 6-Apr-15 3:59am    
Do I need to import any package or add any reference while using the above code?
 
Share this answer
 
v2
Try
how to send email through c# windows application[^]
you will get plenty of link.
have a try and feel free to revert back if you have any problem.
 
Share this answer
 
MAPI[^] is probably the best way to handle this from a windows application - it does not require Exchange, but does provide access to exchange services if that's available, or outlook.
Here is a nice way to access MAPI from .Net
MAPIEx: Extended MAPI Wrapper[^]

look for the .NET Wrapper for CMAPIEx part ...

Best regards
Espen Harlinn
 
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