function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vepakvepak 

mail.setReferences syntax error

 mail.setReferences('References: 1*<'+String.valueOf(b2bcid)+'> CRLF');

Hello guys,

 

if I'm using this in my outbound messages class I'm getting error as

 

System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_MESSAGE_ID_REFERENCE, References header is not valid.: []
Class.WPOSP.B2BRespondtoinquirycontroller.sendResponse: line 59, column 5 External entry point 

 

in the above code String.valueOf(b2bcid) is my record id. I was wondering what will be the syntax of mail.setReferenes method.

 

I also looked at http://tools.ietf.org/html/rfc2822#section-3.6.4 but couldn't understand the syntax.

 

Could you please help me in this.

 

Thanks,

Vamsii

Amit Yadav 9Amit Yadav 9
Hi i am also stuck at the same problem,did you find a solution for this?

Thank You
Nitish Bhardwaj 32Nitish Bhardwaj 32
Hi,

please try a below method,

string str = '<'+recordId.left(9)+'@'+recordId.right(9)+'>';
 mail.setReferences('References: 1*'+str+' CRLF');

(recordId) should be unique

Please mark the best answer if this is helpful,

thanks



 
AndegosuAndegosu
Hello, I tried using that code to set references of an email with the id of a case which worked but when responding to the email Salesforce doesn't match the header information to the existing case and creates a new case. This is related to the update in Winter 21 of the new case threading behavior
sabarinathan Ravindran 4sabarinathan Ravindran 4
Hi Andegosu,
I have tried with getting the pervious mail "Messageidentifer" instead of recordId, it worked as it come in to same case as loop. This doesn't work as you said when creating new email from the case when there is no previous email thread. Do you have any solution ?