Send Email To Gmail Using GmailSend.dll

Initial chamber

Step 1: Open Your Visual Studio 2010, Go to File, New, Projects, then under Visual C# select Windows.

windows application

You can change the name of the project and browse your project to different location too. And then press OK.

Design chamber

Step 2: Now open your Form1.cs file, where we will create our design for sending email to gmail. We will drag 3 labels, 3 textboxes and one button from toolbox to Form1.cs. You will see your Form look like this.

Design

Code chamber

Right click on the blank part of Form1.cs, then click View Code. You will enter in the code part of the form. Write the following code and then Press F5 to run the project.

For GmailSend.dll file - -> https://gmailsend.codeplex.com/

Add some of the namespaces for sending Gmail.

namespaces

If you can’t find these namespaces in the intellisense, then in the Solution Explorer - Right Click, Add References. In Add References, Browse and Find GmaiSend.dll that you had downloaded from the above link.

Add References:

Add References

Code chamber

Open your Form1.cs file where you have to write the code for sending Gmail.

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Windows.Forms;  
  9. using GmailSend;  
  10.   
  11.   
  12. namespace WindowsFormsApplication2  
  13. {  
  14.     public partial class Form1 : Form  
  15.     {  
  16.         public Form1()  
  17.         {  
  18.             InitializeComponent();  
  19.         }  
  20.   
  21.         private void button1_Click(object sender, EventArgs e)  
  22.         {  
  23.             try  
  24.             {  
  25.                 gmail gmlsnd = new gmail();  
  26.                 gmlsnd.auth("your emailid""your password");  
  27.                 gmlsnd.To = textBox1.Text;  
  28.   
  29.   
  30.                 gmlsnd.Subject = textBox2.Text;  
  31.                 gmlsnd.Message = textBox3.Text;  
  32.   
  33.                 gmlsnd.Priority = 1;  
  34.                 gmlsnd.send();  
  35.   
  36.                 MessageBox.Show("Your Mail is sended");  
  37.             }  
  38.             catch (Exception ex)  
  39.             {  
  40.                 MessageBox.Show(ex.Message);  
  41.             }  
  42.              
  43.              
  44.         }  
  45.   
  46.           
  47.     }  
  48. }

Output chamber

Output

In Gmail:

Gmail

Hope you liked it. Have a good day. Thank you for reading.


Similar Articles