Don't save embed image that contain into attachements (like signature image)

前端 未结 4 1660
一向
一向 2020-12-19 15:05

I work on a VSTO in c#. When I click on button I save attachment in a folder. My problem is : when I have a rich email with an image in the signature, I have a element in my

4条回答
  •  生来不讨喜
    2020-12-19 15:29

    We had a need to show only the "Mail Attachments" (not the embedded ones that are used for rendering) in an Outlook Add - In, and this is what that works.

     if (mailItem.Attachments.Count > 0)
            {
                // get attachments
                foreach (Attachment attachment in mailItem.Attachments)
                {
                    var flags = attachment.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x37140003");
    
                    //To ignore embedded attachments -
                    if (flags != 4)
                    {
                        // As per present understanding - If rtF mail attachment comes here - and the embeded image is treated as attachment then Type value is 6 and ignore it
                        if ((int)attachment.Type != 6)
                        {
    
                            MailAttachment mailAttachment = new MailAttachment { Name = attachment.FileName };
                            mail.Attachments.Add(mailAttachment);
                        }
    
                    }
    
                }
            }
    

提交回复
热议问题