Click here to Skip to main content
15,909,466 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to store the sending email from Outlook in the Sql Server. I want email and body to be stored in Sql Server.
Posted
Updated 16-Jun-13 23:53pm
v2

1 solution

Hi;

you can connect to the smtp server and you get the send box.

see this

or you can use the outlook library if you user have it

     OutLook.Application oApp = new OutLook.Application();
     OutLook.NameSpace oNS = (OutLook.NameSpace)oApp.GetNamespace("MAPI");
     oNS.Logon(Missing.Value, Missing.Value, false, true);

     foreach (OutLook.MAPIFolder folder in oNS.Folders)
     {
         string folderName = folder.Name;

         GetFolders(folder);

     }



public void GetFolders(MAPIFolder folder)
 {
     if (folder.Folders.Count == 0)
     {
         string path = folder.FullFolderPath;


         if (foldersTocheck.Contains(path))
         {
             //GET EMAILS.....
             foreach (OutLook.MailItem item in folder.Items)
             {
                 Console.WriteLine(item.SenderEmailAddress + " " + item.Subject + "\n" + item.Body);


             }
         }
     }
     else
     {
         foreach (MAPIFolder subFolder in folder.Folders)
         {
             GetFolders(subFolder);
         }
     }
 }


good luck

jeremy
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900