Search code examples
c#vstooutlook-addinoutlook-redemption

How do i edit the mapi property content disposition for inline image using c#?


I'm trying to add an inline image to the HTML body. How do I edit the content disposition ID. Currently it takes it as normal attachment instead of emebdded attachment?

        string file = GetImageBytes();
        Redemption.Attachment att = mail.Attachments.Add(file, 1, null, "logo");
        att.Fields[0x3712001E] = "image.logo";
        mail.Commit();
        RDOMail msg = Globals.ThisAddIn.session.GetMessageFromID(mailItem.Item.EntryId);

        mail.Item.HTMLBody = CreateHTMLBody(msg, sender, nvd_sii, recipient);

I want add the above attachment as inline attachment. Is there any way I could do it using redemptions?


Solution

  • Instead of setting the content disposition property, I set PR_ATTACH_FLAGS "http://schemas.microsoft.com/mapi/proptag/0x37140003" to 4(for embedded image). This solved the issue. The code below worked

            string file = GetImageFile();
            Redemption.Attachment att = mail.Attachments.Add(file);
            att.Fields[0x3712001E] = "image.logo";
            att.Fields[0x37140003] = 4;
            mail.Commit();
            System.IO.File.Delete(file);
            RDOMail msg = Globals.ThisAddIn.session.GetMessageFromID(mailItem.Item.EntryId);
    
    
            mail.Item.HTMLBody = CreateHTMLBody(msg, sender, nvd_sii, recipient);