• Aman Kumar 196
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
I have to build a Process builder Where If email contains "abc.com" or "def.com" or "ghy.com" then I have to make a checkbox checked.  If someone edit the same email and removed those emails  and checkbox is checked already then it should be unchecked.

Please help me with this
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));
    }   
}
 
I'm getting above error ,can someone help.


public class AssignmentEmail 
{    
    public string toEmail{get;set;}
    public List <string> Address;
    public string Subject{get;set;}
    public string Body{get;set;}
        
    public void SendEmail()
    {
        Messaging.SingleEmailMessage email= new Messaging.SingleEmailMessage();
        
        email.setSubject(Subject);
        email.setPlainTextBody(Body);
        Address= new List <string>();
        Address.add(toEmail); 
        email.toaddresses(Address);
        
    }
}
 
public class SearchAccount_ctrl {
    
    public string city{get;set;}
    public Boolean show{get;set;}
    public integer size{get;set;}
   List<Account> AccList{get;set;}
    
    Public SearchAccount_ctrl()
    {
        Size=0;
        Show=False;
        AccList=new List<Account>();
    }
    
    Public void Search()
    {
        AccList=[Select id,Name,Rating,Industry From Account where Billingcity=:city];
        Size= AccList.size();
        If(size>0)
        {
            show=true;    
        }
        else
        {
            show=false;
        }
        
    }

}
=======================
VF Page:
<apex:page controller="SearchAccount_ctrl">
    <apex:form>
        <apex:pageBlock>
            <apex:pageblocksection >
                <apex:outputLabel id="a1">
                    <apex:pageblocktable title='Search Result' value="{!AccList}" var="item">
                      <apex:column value="{!item.Name}"/>  
                      <apex:column value="{!item.Billingcity}"/> 
                      <apex:column value="{!item.Rating}"/> 
                      <apex:column value="{!item.Industry}"/> 
                    </apex:pageblocktable>
                </apex:outputLabel>
            </apex:pageblocksection>
            <apex:commandButton title="Search" action="{!Search}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>
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));
    }   
}
 
I'm getting above error ,can someone help.


public class AssignmentEmail 
{    
    public string toEmail{get;set;}
    public List <string> Address;
    public string Subject{get;set;}
    public string Body{get;set;}
        
    public void SendEmail()
    {
        Messaging.SingleEmailMessage email= new Messaging.SingleEmailMessage();
        
        email.setSubject(Subject);
        email.setPlainTextBody(Body);
        Address= new List <string>();
        Address.add(toEmail); 
        email.toaddresses(Address);
        
    }
}
 
public class SearchAccount_ctrl {
    
    public string city{get;set;}
    public Boolean show{get;set;}
    public integer size{get;set;}
   List<Account> AccList{get;set;}
    
    Public SearchAccount_ctrl()
    {
        Size=0;
        Show=False;
        AccList=new List<Account>();
    }
    
    Public void Search()
    {
        AccList=[Select id,Name,Rating,Industry From Account where Billingcity=:city];
        Size= AccList.size();
        If(size>0)
        {
            show=true;    
        }
        else
        {
            show=false;
        }
        
    }

}
=======================
VF Page:
<apex:page controller="SearchAccount_ctrl">
    <apex:form>
        <apex:pageBlock>
            <apex:pageblocksection >
                <apex:outputLabel id="a1">
                    <apex:pageblocktable title='Search Result' value="{!AccList}" var="item">
                      <apex:column value="{!item.Name}"/>  
                      <apex:column value="{!item.Billingcity}"/> 
                      <apex:column value="{!item.Rating}"/> 
                      <apex:column value="{!item.Industry}"/> 
                    </apex:pageblocktable>
                </apex:outputLabel>
            </apex:pageblocksection>
            <apex:commandButton title="Search" action="{!Search}"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>