Save embedded Image from Outlook MailItem RRS feed

  • Question

  • Hello,

    I'm trying to save an embedded image from an Outlook mailItem (HTML-Body), but I don't find in which property the embedded image is stored and how I can save it.

    I have tried to get the image from the property .Attachments (I have tried the index 0) but then comes a Exception that the Array-index is out of range. That means, that there is no attachment in the E-Mail.

    But if the image is not stored in "Attachments" where is the image stored and how can I save it to the filesystem?

    Thank you very much in advance for your answers!

    Best regards


    Tuesday, June 28, 2016 6:36 AM


  • I have found the solution by myself.

    The problem was, that I was accessing the MailItem by an other thread. I don't know why but from this thread you can't see the attachments. After putting the Mail-reading-part inside

    this.Dispatcher.Invoke(new Action(() => { ... }));

    it works fine. Then you can access the inline image with this code...

    if (mail.Attachments.Count > 0)
        for (int i = 1; i <= mail.Attachments.Count; i++)
            mail.Attachments[i].SaveAsFile(@"C:\Test\" + mail.Attachments[i].FileName);
    • Marked as answer by hias116 Tuesday, June 28, 2016 11:12 AM
    Tuesday, June 28, 2016 11:12 AM