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
Viliam LomidrevoViliam Lomidrevo 

sendEmailmessage() -> Parent Case required

When sending email message using the sendEmailMessage() method, I am getting the INVALID_OPERATION error Reason is: 'Parent Case required'.

Is it possible to send EmailMessages with empty (or not set) Parent Case field?

Thanks

olegforceolegforce
This is probably what you are looking for. 

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_email_outbound_single.htm
Viliam LomidrevoViliam Lomidrevo

Thanks for your answer.

I am aware of the Single or Mass EmailMessage object that can be sent using the API's sendEmail() method.

However my question is related specifically to sendEmailMessage() method, which is supposed to send an email just by passing the ID of existing EmailMessage record

olegforceolegforce
It is not possible to send with that method without case id
Viliam LomidrevoViliam Lomidrevo

Yes that is true, 

EmailMessage must have the case id set + the status of the email must be 'Draft'. Problem is that using SOAP API it is not possible to create EmailMessage object that has the parent case Id set and in the same time the status of that email is Draft. result is INVALID_OPERATION

So if you want to create a new EmailMessage and immediately send it using sendEmailMessage() web method, you can't do it.

Do you think this is a bug or it was intended to work like this?