Acessing the attachments from email
HI,
I need to access attachments from an email and process the attachments programmatically. I dont mind if the email's are accesed from the server or from microsoft outlook. I also need to mark as read the emails of which the attahcments I have processed....Can someone help me out step by step.
I've been programming in C# for about 6 months or so,

vivek kulkarni132 reputationPosted May 8, 2009, 7:51 AM EDT
Hi,
Here is a link that will help you for extracting attachment.
http://www.codeproject.com/KB/IP/despop3client.aspx
A POP3 Client in C# .NET
Thank You,
Abdulqadir3 reputationPosted May 13, 2009, 5:08 AM EDT
Thanks a lot for the link but I just figured it out this morning... (P.s. I had already visited the link before, It's a great article, but personally I didn't find it as useful)
Qadir
luis reis105 reputationPosted May 29, 2009, 1:44 PM EDT
using System.Collections; using Outlook = Microsoft.Office.Interop.Outlook; Outlook.Application outlook = new Outlook.ApplicationClass(); Outlook.MAPIFolder outBoxfolder = outlook.GetNamespace("MAPI").GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderOutbox); object missing = Missing.Value; // get the namespace object Outlook.NameSpace nameSpace = outlook.GetNamespace("MAPI"); // Logon to Session, here we use an already opened Outlook nameSpace.Logon(missing, missing, true, true); // get the inbox folder Outlook.MAPIFolder inboxFolder = outlook.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox); string filter = ""; string nome =""; l = 0; Outlook.Items items = inboxFolder.Items; items.Sort("[ReceivedTime]", false); items.IncludeRecurrences = true; IEnumerator ir=items.GetEnumerator(); do { if (ir.Current is Outlook.MailItem) { Outlook.MailItem mail = ir.Current as Outlook.MailItem; if (mail.SenderName.Contains("what you want") && mail.FlagStatus == Outlook.OlFlagStatus.olNoFlag) //if (mail.FlagStatus == Outlook.OlFlagStatus.olNoFlag) { int AttachCnt = mail.Attachments.Count; if (AttachCnt > 0) { for (int i = 1; i DataRow dr = dtg.NewRow(); nome = "c:\\folder\\" + dt + mail.Attachments[i].DisplayName; mail.Attachments[i].SaveAsFile(nome); } mail.FlagStatus = Outlook.OlFlagStatus.olFlagComplete; mail.Save(); } } } ir.MoveNext(); } // Release COM Objects //Marshal.ReleaseComObject(inboxTable); Marshal.ReleaseComObject(inboxFolder); // logoff from namespace nameSpace.Logoff(); // release resources //Marshal.ReleaseComObject(nameSpace); Marshal.ReleaseComObject(outlook); GC.WaitForPendingFinalizers(); GC.Collect(); }