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
Charles McDowellCharles McDowell 

email is not sent

I am trying to send an email but it does not send. I test delivery that does not work. One I use the following code,  the log says that there is 1 email invocation but no email is sent.  Is there something that I have to set in order to send email.

<apex:page controller="RequestEmailController">
    <apex:form >
        <apex:pageBlock title="Email">
            <b>Enter Subject  </b>    <apex:inputText value="{!Subject}" maxlength="100" /><p/> <br/>
            <apex:outputLabel for="bod" value="Enter Body"> </apex:outputLabel>
            <apex:inputTextarea value="{!Body}" id="bod" rows="8" cols="60" /><p/>

             <apex:pageBlockButtons > 
             <apex:commandButton value="Send Request" action="{!Send}"  />
            </apex:pageBlockButtons>   

        </apex:pageBlock>
    </apex:form>
</apex:page>

public class RequestEmailController {
    Public String subject {Get;Set;}
    Public String body {Get;Set;}
    List<String> eaddr = new List<String>{'c.mcdowell@sbcglobal.net'};
    
    Public PageReference send(){
        
        messaging.singleEmailmessage email = new messaging.singleEmailmessage();
            email.setSubject(Subject);
            email.setPlainTextBody(Body);
            email.setToAddresses(eaddr);
        
            Messaging.sendEmailResult[] r = messaging.sendEmail(new messaging.SingleEmailMessage[] {email});
        System.debug('The email size is: ' + r.size());
        Return null;
    }

}
 
RKSalesforceRKSalesforce
Hi Charles,

Code is fine. Please Recheck your email address.

Regards,
Ramakant
mukesh guptamukesh gupta
Hi Charles McDowell,

I have tested your code on my side, I have add my email address in your code , it's working fine. Please check your email id , some time mail server takes some time to sending emails. So please wait and check mail

Please Mark AS A BEST ANSWER!

REgards
Mukesh
Charles McDowellCharles McDowell
Mukesh
Yes
  • when I check the log there is 1 email invocation
  • when I use the test delivery function I send myself an email, I do not receive it.
I am using the developers' edition. Is there something I must set in order to send email?

Thanks for your help

Charles
Charles McDowellCharles McDowell
Ok, I got.  The problem is with Yahoo. I change my email to gmail and it works fine

Thanks again