You need to sign in to do that
Don't have an account?
sfdc98
vf email
Hi every one ,tried sending email through vf am not getting any errors and i have given active mail id, but am not receiving the mail when i click on the send button through vf,below is the code..
apex:
public class sendEmailthroughvf {
public string subject {set;get;}
public string Body {set;get;}
List<string>emails=new List<string>{'abc1@gmail.com'};
public PageReference sendEmail(){
messaging.SingleEmailMessage mail=new messaging.SingleEmailMessage();
mail.setSubject(subject);
mail.setHtmlBody(Body);
mail.setToAddresses(emails);
Messaging.SendEmailResult[] r=Messaging.sendEmail(new messaging.SingleEmailMessage[] {mail});
//Messaging.sendEmail(new Messaging.singleEmailMessage[] { mail });
return null;
}
}
vf:
<apex:page controller="sendEmailthroughvf">
<apex:form >
<apex:pageBlock >
<b>Enter Subject:</b> <apex:inputText value="{!subject}"/><p/>
<b>Enter Body:</b><apex:inputText value="{!Body}"/>
<apex:pageBlockButtons location="top">
<apex:commandButton value="send" action="{!sendEmail}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
apex:
public class sendEmailthroughvf {
public string subject {set;get;}
public string Body {set;get;}
List<string>emails=new List<string>{'abc1@gmail.com'};
public PageReference sendEmail(){
messaging.SingleEmailMessage mail=new messaging.SingleEmailMessage();
mail.setSubject(subject);
mail.setHtmlBody(Body);
mail.setToAddresses(emails);
Messaging.SendEmailResult[] r=Messaging.sendEmail(new messaging.SingleEmailMessage[] {mail});
//Messaging.sendEmail(new Messaging.singleEmailMessage[] { mail });
return null;
}
}
vf:
<apex:page controller="sendEmailthroughvf">
<apex:form >
<apex:pageBlock >
<b>Enter Subject:</b> <apex:inputText value="{!subject}"/><p/>
<b>Enter Body:</b><apex:inputText value="{!Body}"/>
<apex:pageBlockButtons location="top">
<apex:commandButton value="send" action="{!sendEmail}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
you deliverability setting should be as below screen
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
settings are same as above screenshot ,acceslevel is All email and Iam not receiving any email.
Thanks
Please try with below code:-
VF page
singleEmailExample
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh