Thursday 1 September 2011

Send E-mail From Gamil

Now it is really simple to send E-mail With attachment and you can also make a HTML body for your Email Body
all you need is a G mail ID


now, we need a .dll to import in our code
download the dll from

Email.dll


after you have downloaded this Dll
we can start coding

Import this Email.dll in your code then,

Solution Explorer>right click references>
Browse>"Path of Email.dll"




Now in code....

Import this namespace

using Email;

Make 2 arrays

/// 'to' this array contains the list of Recipients
/// Warring if any email is wrong the mail will not be sent to the next email ides


string[] to = { "wonder_vikas@rediffmail.com"};

///'att' contains all attachments that should be sent
string[] att = { @"C:\Users\admin\Desktop\autorun3.txt" };





/// make a obj of class Send
Send send = new Send();

/// use SendMail method for sending the mail
///now we talk about parameters
///1. string -- it contains a gmail id of sender
///2.  string -- it contains the password of sender
///3. string[] -- it contains the list of Recipients
///4. string -- subject
///5. string -- body
///6. bool -- body is written in HTML pass true here of false if the body is written simply
///7. string[] -- array of attachments


 send.SendMail("killerof99kings@gmail.com", "password", to, "hi", "hellow", false, att);

just call this function and your work will be done


just copy and paste:-


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Email;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] to = { "wonder_vikas@rediffmail.com", "vik@gmail.com" };

            string[] att = { @"C:\Users\admin\Desktop\autorun3.txt" };


            Send send = new Send();
            send.SendMail("killerof99kings@gmail.com", "password", to, "hi", "hellow", false, att);
        }
    }
}












Feel Free to ask any question.........................


Enjoy the joy of coding

God Bless You
Jai SiyaRam