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
Aman Kumar 196Aman Kumar 196 

In log, I can see the Email has been invoked but not receiving the email

VfPafe:
==========================
<apex:page controller="AssignmentEmail" >
    <apex:form >
        <apex:pageblock title="Send Email">
            <apex:pagemessages id="Showmsg"  />
            <apex:pageBlockSection columns="1">
                <apex:inputText label="To Address:" value="{!toEmail}" />
                <apex:inputText label="Subject:" value="{!Subject}"  />
                <apex:inputTextarea richtext="true" rows="20" value="{!Body}"/>
            </apex:pageBlockSection>
            <apex:pageblockbuttons >
                <apex:commandButton value="Send Email" action="{!SendEmailMain}" rerender="Showmsg"/>
            </apex:pageblockbuttons>
        </apex:pageblock>
    </apex:form>
</apex:page>
=======================================
apex class:
==============================
public class AssignmentEmail 
{    
    public string toEmail{get;set;}   
    public string Subject{get;set;}
    public string Body{get;set;}
    Public Boolean RequiredFieldcheck;
    
    public AssignmentEmail()
    {
        RequiredFieldcheck=true;
    }    
    Public void SendEmailMain()
    {
        If(toEmail=='')
        {
            ApexPages.addmessage ( new ApexPages.Message(ApexPages.Severity.Error,'Enter the Email address'));
            RequiredFieldcheck=false;
        }
        if(RequiredFieldcheck==true)
        {    
            SendEmail() ;  
        }
    }  
    
    public void SendEmail()
    {
        Messaging.SingleEmailMessage email= new Messaging.SingleEmailMessage(); 
        email.setSubject(Subject);
        email.setPlainTextBody(Body);
        List <string> Address = new List <string>();
        Address.add(toEmail);
        email.setToAddresses(Address);
        //Messaging.sendEmail(new messaging.SingleEmailMessage[] {email});
        List <messaging.SingleEmailMessage> mail = new List <messaging.SingleEmailMessage>();
        mail.add(email);
        messaging.sendEmail(mail);
        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'Email Sent successfully!'+' '+toEmail+ ': '+Address +' '+'With Subject : '+Subject));
    }   
}
 
SwethaSwetha (Salesforce Developers) 
HI Aman,
Have you checked the email logs?(https://help.salesforce.com/articleView?id=email_logs_edit.htm&type=5) If so, what is the mail event type you are seeing? (Check https://help.salesforce.com/articleView?id=email_logs_format.htm&type=5 for codes)

It should show D - Delivery. If it doesn't check the email deliverability settings.
 
Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
Ram Chand HeerekarRam Chand Heerekar
Hi Aman,

The code is working absolutely fine. kindly put the debug logs and check throughly.

1) VF 

User-added image
2)Class
User-added image
3)My gmail
User-added image
4) VF Page
User-added image

 
Ram Chand HeerekarRam Chand Heerekar
Hi Aman,

if you got an answer please mark the answer as best so that it would be helpful to others
Aman Kumar 196Aman Kumar 196
Below is the screenshot of my Deliveribility setting
User-added image

I requeste the logs, but I couldn't find what's wrong. Email Event is shows as p and R. 
     10.218.209.157