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

setwhatid in quote for apex email

Hi everyone,
I'm developping an automatic email in an apex class.

I'm trying to link my email to a quote with the methode setWhatId, but it don't work with quote...

Can you help me or give me another solution plese ?

This is my code:
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});

Best Answer chosen by CotralLabWebDev
Hanimi ReddyHanimi Reddy
Hope this will solve your issue..

All Answers

This is my error :

SendEmail failed. First exception on row 0; first error: INVALID_ID_FIELD, Only accounts, assets, campaigns, cases, contracts, opportunities, orders, products, solutions and custom objects are allowed as whatId.: [whatId, MYQUOTEID]
Hanimi ReddyHanimi Reddy
Hope this will solve your issue..
This was selected as the best answer
Yes it works ! Thanks a lot :)
Mitesh SuraMitesh Sura
Hi fsonnet,

Can you please help? When you say "it works" , are you able to use email template along with Quote merge fields as well? There are 2 issues with WhatId
- Associating email to quote
- Using email template with Quote merge fields

Are you able to solve 2nd issue as well? Thank you for your time.