How to remove particular attachment from mail message

email
activities

#1

Hi,

I have scenario to forward an outlook email with Attachment. Used Send Outlook Mail Message Activity and passed the Mailmessage variable in Forward parameter. The email forwarded successfully but the problem is signature images are also sent as attachments in the email.

I tried Save attachment activity and could see the Signature images also getting saved in the folder. Can anyone help me with a logic to remove the signature attachments alone from mail message.


#2

Try this way

Create a variable say signAttachment as System.Net.Mail.Attachment type

signAttachment = email.Attachments.Where(Function(s) s.Name="signature.jpg").First

Pass this into Invoke Method (below) as System.Net.Mail.Attachment Type

Then do Send Outlook.

image

image


#3

@vvaidya,
Thank a lot using this way i can remove the signature attachment. But what if not sure on the image name or multiple signature attachment comes in. Is there way to only save the attachment ignoring the signatures.


#4

#1. If you are not expecting any Images in your Original Attachment, you can remove them from your Attachments Collection.

email.Attachments.Where(Function(s) s.Name.Contains(".png"))

Remove this collection using For each loop

#2. This is a bit complex. You have to read your email html body and get all the cid images using Regex and remove them from your attachments.

StreamReader reader = new StreamReader(email.AlternateViews(0).ContentStream)
strHtml = reader.ReadToEnd()

get Image named from this the above string using Regex.

Thanks,
Vinay


#5

Hi, did you find a solution for this problem? Could you please share it… I have exactly the same problem…
Thank you in advance!!