How to remove particular attachment from mail message

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.

1 Like

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

1 Like

@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.

#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

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

1 Like

Hi,

I would like to remove the disclaimer message from the email. Can someone suggest how to do it?

Regards,

PrameelaJ

How to check whether the attached image in the mail body is signature image or not???..

1 Like