You need to sign in to do that
Don't have an account?
Email Service Adding HTML Paragraph Tag to Email Body
I have an email service setup to automatically create records within a custom object that we have setup. The email service parses the email's Subject into the name of the new record, and the email's Body into a "Description" custom field within the new record.
The email service works great, and can parse the email's content perfectly regardless of whether the email is plain text or an html email. However, whenever an html email goes through the email service, it adds the following html tag to the beginning of the "Description" field.
p{margin-top:0px; margin-bottom:0px;}
Here's the code of the Apex Class I am using for this email service...
global class createMatrixRecordFromInboundEmail implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging.inboundEmail email, Messaging.InboundEnvelope env) { Messaging.InboundEmailResult result = new Messaging.InboundEmailResult(); String myEmailBody = email.HTMLBody; IF(String.isNotBlank(myEmailBody)) { myEmailBody = email.HTMLBody; } ELSE { myEmailBody = email.plainTextBody; } List<Matrix_Team__c> mtrList = new List<Matrix_Team__c>(); Matrix_Team__c mtr = new Matrix_Team__c(RecordTypeId = '012Z00000000WUD', OwnerId = '00GZ00000014KGG', Name = email.Subject, Description__c = myEmailBody); mtrList.add(mtr); insert mtrList; System.debug('New record(s): ' + mtrList); if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) { for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) { Attachment attachment = new Attachment(); attachment.ParentId = mtr.Id; attachment.Name = email.binaryAttachments[i].filename; attachment.Body = email.binaryAttachments[i].body; insert attachment; } } result.success = true; return result; } }
Do you know why the paragraph html tag is being added in whenever an html email goes through my email service?
Thanks!
We are currently experiencing the same issue, where 'p{margin-top:0px; margin-bottom:0px;}' is added to the Email Messages.
Thank you.