You need to sign in to do that
Don't have an account?
ErrorProne
targetObjectId is optional?
the documentation indicates this field is optional, however when i omit it and use toAddresses and WhatId instead I get an error that indicates targetObjectId is required?
heres the code:
heres the code:
var message = new sforce.SingleEmailMessage(); message.replyTo = "myemail@myemail.com"; message.toAddresses = email; message.whatId= comment_id; message.templateId = "00XG0000001M0X7"; var result = sforce.connection.sendEmail([message]); console.log(result);
Yes According to docuementation.
Targetobject id is Optional. The object ID of the contact, lead, or user the email will be sent to. The object ID you enter sets the context and ensures that merge fields in the template contain the correct data
Do not enter the object IDs of records that have the Email Opt Out option selected.
All emails must have a recipient value in at least one of the following:
toAddresses
ccAddresses
bccAddresses
targetObjectId
targetObjectIds
https://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_sendemail.htm
IF it helps you than please mark it as a solution and ENJOY APEX
If you set "toAddress" and didn't set "templateID" then targetObjectId is optional.
If you set "templateID" then targetObjectId is required.