You need to sign in to do that
Don't have an account?
BMC Group
Save error: Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setTreatTargetObjectAsRecipient(Boolean)
Hi everyone,
I am getting an error on below mentioned line when compiling in an apex class but it runs in Execute Anonymous Window :
msg.setTreatTargetObjectAsRecipient(false);
Error : Save error: Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setTreatTargetObjectAsRecipient(Boolean).
Kindly help. Thanks in advance.
I am getting an error on below mentioned line when compiling in an apex class but it runs in Execute Anonymous Window :
msg.setTreatTargetObjectAsRecipient(false);
Error : Save error: Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setTreatTargetObjectAsRecipient(Boolean).
Kindly help. Thanks in advance.
please check once below link.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm#apex_Messaging_SingleEmailMessage_setTreatTargetObjectAsRecipient
setTreatTargetObjectAsRecipient(treatAsRecipient)
Optional. If set to true, the targetObjectId (a contact, lead, or user) is the recipient of the email. If set to false, the targetObjectId is supplied as the WhoId field for template rendering but isn’t a recipient of the email. The default is true.
Signature
public void setTreatTargetObjectAsRecipient(Boolean treatAsRecipient)
Parameters
treatAsRecipient
Type: Boolean
Thanks
Varaprasad
Thanks for your response.
I have already gone through the above document but still I'm not able to resolve the error.
Here is my code snippet and I have highlighted the error line -
msg.setTreatTargetObjectAsRecipient(false); ---> This line is throwing Save error: Method does not exist or incorrect signature: [Messaging.SingleEmailMessage].setTreatTargetObjectAsRecipient(Boolean)
----------------------------------------------------------------------------------
Any further help would be highly appreciated.
This method was introduced in Winter '16 release. Try updating the API version of your apex class to the latest one. It should work.
https://releasenotes.docs.salesforce.com/en-us/winter16/release-notes/rn_apex_new_classes_methods.htm