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
Charlie Cox 1Charlie Cox 1 

Send emails with Apex in a developer edition

I am trying to send emails from my apex class in my developer edition of salesforce. Here is the apex code:

    public void sendEmail(Contact con) {
        try {            
            Messaging.reserveSingleEmailCapacity(1); // Reserve email message from capacity
            
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); // Instantiate new email message
            
            mail.setToAddresses(new String[]{con.Email}); // Set to address to contact's email
            mail.setUseSignature(false); // Don't use signature
            
            /* Set reply to and from address based on if this is a conference email or not */
                
                mail.setReplyTo('myEmail@yahoo.com');
                mail.setOrgWideEmailAddressId('0D2o0000000Ce18'); 
            
            /* Set subject/body if conference confirmation email */
                
                mail.setSubject('Test');
                mail.setHtmlBody('This worked');
                
            /* Set subject/body if companion confirmation email */
             
            
            Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); // Send email'
            System.debug('Sent the Email');
            
        /* Display error message if email send was not successful */
        } catch (DmlException e) {
            
            System.debug('The following exception has occurred: ' + e.getMessage());
        }
    }

The issue is that I never recieve the email. I checked the debug logs and they show this:


20:23:59.089 (89826472)|SYSTEM_METHOD_ENTRY|[65]|Messaging.sendEmail(List<Messaging.Email>) 20:23:59.098 (98211855)|EMAIL_QUEUE|[65]|replyTo: charliecox17@yahoo.com, subject: NUBS Conference Confirmation, bccSender: false, saveAsActivity: true, useSignature: false, toAddresses: [charliecox2306@gmail.com], htmlBody: This worked, 20:23:59.098 (98263315)|SYSTEM_METHOD_EXIT|[65]|Messaging.sendEmail(List<Messaging.Email>) 20:23:59.098 (98283765)|SYSTEM_METHOD_ENTRY|[66]|System.debug(ANY) 20:23:59.098 (98300704)|USER_DEBUG|[66]|DEBUG|Sent the Email

Which makes me believe that the email is sending, I am just not recieving it. I have checked my spam folder and tried sending it to multiple emails with no luck. Also my access setting for deleverability is set to all email.

Thanks for any help!
 
Shailesh DeshpandeShailesh Deshpande
Check the "Deliverability" settings under "Email Administration". Here "Access to Send Emails" should be set to "All Emails".
Pankaj_GanwaniPankaj_Ganwani
Can you please remove mail.setOrgWideEmailAddressId('0D2o0000000Ce18'); and then try to send email? 
Charlie Cox 1Charlie Cox 1
@Shailesh Deshpande: I have already done that, see above
@Pankaj Ganwani: I have commented out that line still do not recieve an email.

Thanks!