Return to Snippet

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

Initial Code

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

        ImapClient client = new ImapClient("", 993, "MedicalLearningSystem", "MLSMLSMLS");


            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.


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

            //login to the remote server.


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

            // select the inbox folder


            // 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


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


        catch (Exception ex)




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