Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to send email using windows application in c#.net?
Posted
Updated 23-Apr-13 2:15am
v2

Create a MailMessage and a SmtpClient and send it.

C#
MailMessage msg = new MailMessage();
msg.From = new MailAddress("from@gmail.com", "Display name");
msg.Subject = "Hello mail!";
msg.Body ="This is my email";
// Set more properties if you like.

SmtpClient client = new SmtpClient();
// Set client properties. Authentication, smtp server etc. or use app.config (see below)
client.Send(msg);


You could configure you're smtp-client in app.config file.

XML
<system.net>
    <mailsettings>
      <smtp from="from@gmail.com">
        <network host="smtp.mail.com" port="587" username="from@mail.com" password="***" />
      </smtp>
    </mailsettings>
  </system.net>
 
Share this answer
 
v4
Comments
Pheonyx 23-Apr-13 8:13am    
There would be a app.config, not a web.config as he is asking for a windows application and not a website.
StianSandberg 23-Apr-13 8:15am    
thank you. I've edited my answer.
Try some initial research, there are various approaches you can take depending on the context of your e-mail system.

http://bit.ly/11gXx2Z[^]
 
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