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
Aidel BruckAidel Bruck 

contentversion insert error

I 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' 
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);
}
sagar jogisagar jogi
Have you checked your email limit in your org?
Please use below steps to check email limit in your org.

1. Ensure you are logged into the organization where you want to verify your limits.
2. Navigate to https://workbench.developerforce.com/login.php
3. Accept any oauth prompts to complete authentication
4. On the Jump to picklist select "REST Explorer".
5. Click Select.
6. From the options presented select:  /services/data/vXX.0/limits
7. Click "Execute".
8. Select the SingleEmail area to view the daily maximum and remaining calls.



 
Aidel BruckAidel Bruck
I have Max:5000 , Remaining: 5000
Aidel BruckAidel Bruck
Anybody else? This is quite urgent
I tried to move the messaging.send() to an different class and called in asyncronously but I still don;t get it.