You need to sign in to do that
Don't have an account?
Ajay Ghuge 6
Get attachments from EmailMessage
Hi Folks,
I need to get the attachments from EmailMessage. Is there any way to get it ? EmailMessage object has a property called hasattachments but how to get attachments and its body ?
Regards,
Ajay
I need to get the attachments from EmailMessage. Is there any way to get it ? EmailMessage object has a property called hasattachments but how to get attachments and its body ?
Regards,
Ajay
string strEmailBody = email.htmlBody.replaceAll('<br/>', '\n');
strEmailBody = strEmailBody.replaceAll('<br />', '\n');
string HtmlPattern = '<.*?>';
Matcher match = Pattern.compile(HtmlPattern).matcher(strEmailBody);
strHTMLEmailBody.stripHtmlTags();
All Answers
Below is the sample code to send Attachement with some message in Mail :
Hope this helps you!
Please accept my solution as Best Answer if my reply was helpful. It will make it available for other as the proper solution.Let me know if anything else.
Best Regards
Narveer
Thanks for you reply. But this is not what I am looking for. I am sending email from salesforce for example : Email Quote and I want to get attachment from that email.
I hope you got my point.
Regards,
Ajay
string strEmailBody = email.htmlBody.replaceAll('<br/>', '\n');
strEmailBody = strEmailBody.replaceAll('<br />', '\n');
string HtmlPattern = '<.*?>';
Matcher match = Pattern.compile(HtmlPattern).matcher(strEmailBody);
strHTMLEmailBody.stripHtmlTags();
Were you able to figure out how to get attachments from the EmailMessage object?
Thank you.
Sincerely,
Aditya
hi Guys,
I am also looking exactly for the same. I want to be able to process incoming Email with attachments and add them to the EmailMessage record.
I am able to correctly create an Email Message but not able to add attachment to that record?
Was wondering if we have to use something like ContentDocument?
If any of you found something after the last comment on Oct 29, 2018, Please let me know.
Thanks,
Chellappa
I think i got the answer. We indeed have to create a Content Document record with all related records like Contentversion, ContentDocumentLink etc.
Chellappa
For that, please try the following resource:
https://retrology.net/how-to-create-a-file-from-an-email-attachment-in-salesforce