Reading bytes from Outlook email attachment RRS feed

  • Question

  • Hi all,

    I am trying to read byte[] content from Outlook attachment from an incoming email without actually needing to save the attachment on harddisk. I don't see a method/property that would let me read the bytes. I need the bytes to upload the attachment to a SharePoint location. Is there  do that?

    MailItem currentMail = Globals.ThisAddIn.m_Application.ActiveInspector().CurrentItem;
    foreach (Attachment attachment in currentMail.Attachments)
        // This is not working
        Utility.UploadFile(dmSettings, url, attachment.PathName);

    Within the Utility.UploadFile method, I try to pass the attachment.PathName and reading the bytes from the attachment from its Path but this does not work since the attachment is not on the machine itself.

    Please help. Thanks!

    Tuesday, October 1, 2013 5:22 PM


  • The Outlook object model doesn't have a method to do what you want. With the object model you need to save the attachment to the file system before manipulating it.

    If you can use Extended MAPI (C++ or Delphi only) or Redemption ( you can access the actual bytes of the attachment from the attachment table on the email.

    Ken Slovak MVP - Outlook

    Tuesday, October 1, 2013 6:51 PM