You need to sign in to do that
Don't have an account?
Charles 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;
}
}
<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;
}
}
Code is fine. Please Recheck your email address.
Regards,
Ramakant
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
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
Thanks again