You need to sign in to do that
Don't have an account?
![Aidel Bruck Aidel Bruck](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
not getting email sent by trigger
I posted this question yesterday, but didn't really get any solutions, so here goes again:
have the following trigger that is obviously working (I checked the log), But no email is being sent out.
I check that the deliveribility is set to 'all emails'
I checked the single email limits and they are fine,
I piut the messaging.send() into an asycronous function
And still no luck
Please advice
This is the code
trigger NewFileAlert on ContentDocument (after insert)
{
List<Messaging.SingleEmailMessage> mails =
new List<Messaging.SingleEmailMessage>();
for (ContentDocument newDoc : Trigger.new)
{
Messaging.SingleEmailMessage mail =
new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(allthepeople@everybody.com);
...
mail.setToAddresses(sendTo);
mail.setReplyTo('me@gmail.com');
mail.setSenderDisplayName('Aidel Bruck');
mail.setSubject('New Document Added');
String body = 'Please note: A new document has been added/n ';
body += 'File name: '+ newdoc.title+'/n' ;
body += 'Created By: '+ newdoc.createdbyid+ '/n';
body += 'Created Date: '+ newdoc.CreatedDate+ '/n';
body += 'link to file: '+ System.URL.getSalesforceBaseUrl().getHost()+newdoc.id;
mail.setHtmlBody(body);
mails.add(mail);
}
Messaging.sendEmail(mails);
}
have the following trigger that is obviously working (I checked the log), But no email is being sent out.
I check that the deliveribility is set to 'all emails'
I checked the single email limits and they are fine,
I piut the messaging.send() into an asycronous function
And still no luck
Please advice
This is the code
trigger NewFileAlert on ContentDocument (after insert)
{
List<Messaging.SingleEmailMessage> mails =
new List<Messaging.SingleEmailMessage>();
for (ContentDocument newDoc : Trigger.new)
{
Messaging.SingleEmailMessage mail =
new Messaging.SingleEmailMessage();
List<String> sendTo = new List<String>();
sendTo.add(allthepeople@everybody.com);
...
mail.setToAddresses(sendTo);
mail.setReplyTo('me@gmail.com');
mail.setSenderDisplayName('Aidel Bruck');
mail.setSubject('New Document Added');
String body = 'Please note: A new document has been added/n ';
body += 'File name: '+ newdoc.title+'/n' ;
body += 'Created By: '+ newdoc.createdbyid+ '/n';
body += 'Created Date: '+ newdoc.CreatedDate+ '/n';
body += 'link to file: '+ System.URL.getSalesforceBaseUrl().getHost()+newdoc.id;
mail.setHtmlBody(body);
mails.add(mail);
}
Messaging.sendEmail(mails);
}
Try this:
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
Salesforce Freelance Consultant/Developer/Administrator
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1
Now I'm really stumped.
The log says that the email was sent.