You need to sign in to do that
Don't have an account?
Raffi
what am I missing?
Hello,
I created this very simple VS page and supporting cotroller to send out an email upon page load. The send() function executes fine, but the recepient does not get the email. I've succesfully run the Email Deliverability Tool and checked corporate mail filter without success. I must be missing something very obvious here.
Thanks,
Raf
<apex:page controller="sendEmailController"> <apex:outputText value="{!errorMessage}"/> </apex:page> public class sendEmailController { public String errorMessage {get; set;} public sendEmailController(){ send(); } public PageReference send(){ Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage(); email.setSubject('Test email from Salesforce'); String[] toAddresses = new String[] {'username@company.com'}; email.setToAddresses(toAddresses); email.setPlainTextBody('sent from quoteSendToCop'); Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email}); if (!r.get(0).isSuccess()) { System.StatusCode statusCode = r.get(0).getErrors()[0].getStatusCode(); errorMessage = r.get(0).getErrors()[0].getMessage(); } else {errorMessage = 'success';} return null; } }
I got it sorted out by adding action="{!send}" attribute to visualforce page tag like so:
Thanks for the help,
Raffi
All Answers
Plz share the debug logs
Thansk,
Raf
I have worked with Email classes and all the emails triggered from Apx classes were found in my Spam box.
Did you set something for 'toAddress' ? It seems like to be coming null value.
just try to set value before this line and check the debugs.
Yes, toAddreesses is populated with string array of sizes of 1-4 with my different email addresses ( I tried multiple variants). Nothing in SPAM or junk mail folders for any of those accounts, no emails logged as coming in either. Interestingly, a single email message arrived to my gmail account after reloading the page about 10 times. I was also able to create email alert through workflow and that's coming in fine.
Can you try these similar codes just like yours, I just added an attachment in email,I you do not need skip this part.
I got it sorted out by adding action="{!send}" attribute to visualforce page tag like so:
Thanks for the help,
Raffi