none
Identify Outlook attachments in .net development RRS feed

  • Question

  • In the .net development program, the mail object is taken, and we get all the attachments of the mail in the code by means of (mail.attachment[i]). How do we tell which attachments are attachments in the body of the Outlook, which are the illustrations in the body and which are the images in the signature file. In particular, the HTML, RTF, TXT format difference, at present we can not distinguish which pictures are attachments, which pictures are the body of the message, Which pictures are signature files.
    Monday, August 6, 2018 1:43 AM

All replies

  • Hello 金乾,

    First at all, I don't think the picture in body and the picture in signature are different thing. I think they are both picture in body picture. And during my researching and testing, I did not found any solution to identify them.

    In Plain Text format mail,there is no picture in mail body in mail body. Pictures in attachments collection is indeed an attachment.

    If HTML format, we could use the Attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x7FFE000B") to get the PR_ATTACHMENT_HIDDEN property. If the return value is true, the attachment is a body picture.

    In Rich Text format mail. The PR_ATTACHMENT_HIDDEN property does not work. All the properties of an attachment picture or a body picture will return true. The only workaround I could find is to comparing their filename. An attachment will keep it original file name but a body picture will be format as specific format, such as 

    Picture (Device Independent Bitmap) 1.jpg

    Picture (Device Independent Bitmap) 2.jpg

    You could try to try to pare the filename to confirm if it is a body picture or attachment picture.

    By the way, this workaround will also works for HTML format mail. The format for HTML Mail is 

    image001.jpg
    image002.jpg

    ..

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 7, 2018 7:50 AM
  • Thank you very much for your answer. The method we currently find is to distinguish whether the image is an attachment or a body illustration by looking at whether the attachment is in the specified temporary cache path. However, this method can only be effective for newly created mails. If it is a forwarded mail, and there are pictures in the attachment or there are pictures in the body , it can not be distinguished.
    Thursday, August 9, 2018 7:55 AM
  • Thank you very much for your answer. The method we currently find is to distinguish whether the image is an attachment or a body illustration by looking at whether the attachment is in the specified temporary cache path. However, this method can only be effective for newly created mails. If it is a forwarded mail, and there are pictures in the attachment or there are pictures in the body , it can not be distinguished.
    Tuesday, August 14, 2018 2:14 AM