You need to sign in to do that
Don't have an account?
Adnan Sunelwala
Not receiving email using sendEmail method
hi,
I am new to Salesforce and trying to build app 'Build a Conference Management App'. I had written a simple class to send email in my previous trailhead modules and was able to receive email then but for some reason not receiving any email now.
Could anyone please help track the issue?
public with sharing class EmailManager {
//Public Method
public static void sendMail(String address, String subject, String body) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {address};
mail.setToAddresses(toAddresses);
mail.setSubject(subject);
mail.setPlainTextBody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
I am trying to test above method by writing below code using 'Execute Anonymous Window'
String address = 'adnansun2002@yahoo.co.in';
String subject = 'Speaker Confirmation';
String body = 'Thank you for speaking at the conference.';
EmailManager.sendMail(address, subject, body);
I am new to Salesforce and trying to build app 'Build a Conference Management App'. I had written a simple class to send email in my previous trailhead modules and was able to receive email then but for some reason not receiving any email now.
Could anyone please help track the issue?
public with sharing class EmailManager {
//Public Method
public static void sendMail(String address, String subject, String body) {
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {address};
mail.setToAddresses(toAddresses);
mail.setSubject(subject);
mail.setPlainTextBody(body);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
I am trying to test above method by writing below code using 'Execute Anonymous Window'
String address = 'adnansun2002@yahoo.co.in';
String subject = 'Speaker Confirmation';
String body = 'Thank you for speaking at the conference.';
EmailManager.sendMail(address, subject, body);
Popular email service providers such as Gmail and Yahoo email servers are blocking emails forwarded from salesforce.com IP addresses.
Came to know about this through Setup-->Email Administration-->Test Deliverability.
All Answers
I just ran your code exactly as is and it worked flawlessly for me. Have you made sure to check your junkmail or junkmail filter to see if its getting hung up there?
1) http://amitsalesforce.blogspot.in/search/label/Email
Let us know if this will help you
Thanks
Amit Chaudhary
Is there any governor limit for sending emails from developer org?
@Bryan James - I have checked my junk/spam folders unfortunately it is not present.
@Amit Chaudhary 8 - Email id is correct. I have tried with few other ids as well and it doesn't work.
@Nayana K - It is already set to 'All Email'.
Popular email service providers such as Gmail and Yahoo email servers are blocking emails forwarded from salesforce.com IP addresses.
Came to know about this through Setup-->Email Administration-->Test Deliverability.
Your code worked absolutely fine. But when I ran executed the same flow multiple time I got the limit error : SINGLE_EMAIL_LIMIT_EXCEEDED, Email limit exceeded: [] . So definitely there is a governor limit on SingleEmailMessage.
Please refer the link : https://developer.salesforce.com/forums/?id=906F0000000AgPFIA0
Hope this solves your problem.
Let me know if you are still facing any other issues.
Please mark this as a best answer.
Thanks!
Exactly the mails are getting blocked on yahoo and gmail if you will try with some other domain its working absolutely fine