You need to sign in to do that
Don't have an account?

NO_MASS_MAIL_PERMISSION
Hi !
I have this trigger to send e-mail based on the field "e_mail__c":
trigger Email_EnviodeLayout_AR on Task (after update) { List<Id> TaskMap = new List<Id>(); for(Task tsk : [select e_mail__c, subject, link_do_ar__c, status from Task]) { if(tsk.subject == 'AR - Envio do primeiro layout' && tsk.status == 'Concluído') { Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {tsk.e_mail__c}; mail.setToAddresses(toAddresses); mail.setSubject('Duomind'); String template = 'Hello {0}, \nYour task has been modified. Here are the details - \n\n'; template+= 'Veja suas fotos clicando aqui - {1}\n'; List<String> args = new List<String>(); args.add(tsk.link_do_ar__c); // Here's the String.format() call. String formattedHtml = String.format(template, args); mail.setPlainTextBody(formattedHtml); Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail}); } } }
But It's giving me this error:
- Email_EnviodeLayout_AR: execution of AfterUpdate caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: NO_MASS_MAIL_PERMISSION, Single email is not enabled for your organization or profile. Single email must be enabled for you to use this feature.: [] Trigger.Email_EnviodeLayout_AR: line 22, column 1
It explains about the same issue
All Answers
It explains about the same issue
On a side note, it looks like this is an issue with your query. There is no where condition in the query, which means it will send an email for all tasks in the system and will run into governor limits down the road.
Try replacing the following line
for(Task tsk : [select e_mail__c, subject, link_do_ar__c, status from Task])
with
for(Task tsk : trigger.new)
If you need to query the database again then try this
for(Task tsk : [select e_mail__c, subject, link_do_ar__c, status from Task where Id in : trigger.new])
Thanks CodeWizard, you are right too.
I changed here.
If System.Email.Deliverability something something? :)
Thanks,
Pete