Return to Snippet

Revision: 49250
at July 18, 2011 23:06 by elean


Initial Code
http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/displaying-email-information-on-screen.html

protected void Button1_Click(object sender, EventArgs e)
    {
        //create imapclient with host, user and password

        ImapClient client = new ImapClient("imap.gmail.com", 993, "MedicalLearningSystem", "MLSMLSMLS");

        try
        {

            System.Console.WriteLine("Connecting to the Imap server");

            //connect to the remote server.

            //Note:If you use Connect(true), it will invoke the login internal.

            //        Otherwise, you need to call login sequently.

            client.Connect();

            System.Console.WriteLine("Connected to the Imap server");



            //login to the remote server.

            client.Login();



            System.Console.WriteLine("Logged in to the Imap server");


            // select the inbox folder

            client.SelectFolder(ImapFolderInfo.InBox);



            // get the message info collection             

            ImapMessageInfoCollection list = client.ListMessages();



            // download each message

            for (int i = 0; i < list.Count; i++)
            {
                String From = list[i].From.ToString();
                String To = list[i].To.ToString();


                //save the eml file locally

                client.SaveMessage(list[i].UniqueId, "C:\\Users\\L33505\\Desktop\\MLS(8Jul)\\Inbox(Emails)\\" + list[i].UniqueId + ".eml");

            }



            //Disconnect to the remote Imap server

            client.Disconnect();

            System.Console.WriteLine("Disconncect to the Imap server");

        }

        catch (Exception ex)
        {

            System.Console.Write(ex.ToString());

        }



    }

Initial URL


Initial Description
Hi, i am meeting problem on extracting out my gmail content to database. I have already connect my gmail to imap server and is able to retrieve out and save my gmail message into my computer local drive : temp folder.



However, i am meeting problem on how to store my gmail message to database.This is the url that I had taken from this website.

Initial Title
How to extract email content and store into database

Initial Tags


Initial Language
C#