Showing posts from March, 2013

Send email using C# - details

Here are the details for the classes and properties used in my previous post:

Simple Mail Transfer Protocol is an Internet standard for email transmission across IP networks.

System.Net.Mail: It is namespace contains classes used to send e-mail to a Simple Mail Transfer Protocol server for delivery.

In the previous post,  following two classes of System.Net.Mail are used:

MailMessage - represents the contents of mail  message.SmtpClient - transmit email to the SMTP host that you designate for mail delivery.Note: We can also use "Attachment class" to create mail attachment.
Details about properties and functions of MailMessage class which are used in our program: MailMessage.From - Gets or Sets the from address for current email messageMailMessage.Subject - Gets or Sets the subject line for current email messageMailMessage.Body - Gets or Sets the message bodyMail.To - Gets the address collection that contains the recipients of current email messageMail.To.Add() adds the recipients …

Send email using C#

In my previous post I wrote about sticky notes type application. By using that application a user is able to take small notes. As soon as user closes the notes, the application saves the user notes. So next time when user again launches the application, then user is provided with his notes.

Now I am adding one more functionality to this application. By using this functionality user will be able to send his notes to a specified email. 
To implement this functionality we need to add following libraries in the project: using System.Net.Mailusing System.Net.Mime
Add a link label at the bottom of the form. On the Click event of link label write the logic for sending email. 
Here is the code snippets:

            SmtpClient SmtpServer = new SmtpClient();  SmtpServer.Credentials = new System.Net.NetworkCredential("", "xyz");
            SmtpServer.Port = 587;
            SmtpServer.Host = "";             SmtpServer.EnableSsl = true;             …