none
Deleting the image from the outlook email RRS feed

  • Question

  • Hi

    i had a requirement that i need to remove the image from the emails using VBA / C# Code

    Before

    After 

    Thank you in Advance.


    - Ram

    Tuesday, January 8, 2013 1:24 PM

All replies

  • Is that image from an attachment or is it from external site?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, January 8, 2013 1:47 PM
  • do you just want to remove them froom being displayed in mail's body or remove them completly from mail (so image will not be available even as attachment)?
    Tuesday, January 8, 2013 2:09 PM
  • the image is dispalyed in the body of the email. i need to remove it .

    - Ram


    • Edited by David Billa Tuesday, January 8, 2013 3:07 PM
    Tuesday, January 8, 2013 3:07 PM
  • Where does it come from? External website? Or an image attachment?

    What is the HTML body?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, January 8, 2013 3:29 PM
  • do you also need to remove images from mail's signature? or only from 'body'? and please answer Dmitry's questions.
    Tuesday, January 8, 2013 5:35 PM
  • yes i need to reply image from both body and signature

    - Ram

    Wednesday, January 9, 2013 1:48 PM
  • Ram,

    please help us help you - you need to be a *lot* more specific if you want a meaningful answer.

    There are 2 way to show an image - <img> tag and its src attribute in the HTML body (see MailItem.HTMLBody property) can reference an image using either an external URL or refer to a message attachment via the content id property - <img src="cid:xyz"> where xyz is the value of the PR_ATTACH_CONTENT_ID MAPI property.

    In both cases you will need to modify the HTMLBody property appropriately to remove the <img> tag. In the latter case you also need to remove the image attachment (accessible  through the MailItem.Attachments collection).


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, January 9, 2013 2:07 PM
  • hi 

    thank you for analyzing my problem statement.

    i need to remove the image from the body of the email either it is an seperate image or signature . that's it


    - Ram

    Wednesday, January 9, 2013 2:14 PM
  • then just follow Dmitry's advice or give it a twist:

    1. like Dmitry said - take htmlbody of mail, either manually parse it or load into html agility pack and remove all img elements, then set back htmlbody

    2. use mailitem.GetInspector.WordEditor to obtain access to Document interface from word api and remove images using this API

    i think first approach is easier

    Wednesday, January 9, 2013 2:22 PM
  • Ok, and what exactly are you having a problem with? HTMLBody? Attachments collection?

    How do you modify the HTMLBody property? Please show your code and be specific.

    People here can answer your questions, but nobody will actually write the complete code for you.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, January 9, 2013 2:24 PM