New answers tagged


Based on the doc, setWhatId(whatId) If you specify a contact for the targetObjectId field, you can specify an optional whatId as well. This helps to further ensure that merge fields in the template contain the correct data. In your code, you set a User Id to targetObjectId field.


To resolve, verify the following permissions on the affected user's profile: 'Send Email' permission is enabled. And try this too if(u.Email != null && u.Email!='') If you need any more help let me know ?


A single File (ContentDocument) can have many Versions (ContentDocumentVersion) which all link to the same record (ContentDocumentLink). Your code is pulling all the versions for the record which will include current and old versions. The easiest fix is to include isLatest to only pull the latest version of files. List<ContentVersion> versions = [...


Florian's comment explains that the "Sandbox" prefix will disappear in Production. For the senderDisplayName and mail id of the user showing, what's the value of what you're passing into setSenderDisplayname()? I copied and pasted your code and was able to see it display correctly. Be aware it's still using the user's email address from Salesforce to send ...


check if the user has access right to Enrollment__c and contact object. I think you forgot to set the template Id also email.setTemplateId(tpl.Id);

Top 50 recent answers are included