I have below action function in vf page
<apex:actionFunction name="changeOwnership" action="{!changeOwnership}" rerender="changeOwnershipId" oncomplete="ownerShipChangedComplete()">
and in the controller I have below method
public void changeOwnership() {
String usId = ApexPages.CurrentPage().getParameters().get('usId');
String userEmail = ApexPages.CurrentPage().getParameters().get('userEmail');
try{
sendEmailMethod(usId,userEmail);
}
catch(Exception e){
System.debug(e);
}
}
the send Email Method is below
public void sendEmailMethod(String usId,String userEmail){
try{
System.debug('sending email');
Messaging.singleEmailmessage Email = new Messaging.singleEmailmessage();
email.setsubject('test');
email.setPlainTextbody('test');
email.setToAddresses(new String[] { usId });
email.saveAsActivity = false;
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
System.debug('###email sent');
}
catch(exception e){
System.debug('cannot send email'+e);
}
}
I tried to run the send email code in developer console and it works fine and I get the email but it is not working through my action function. I checked the debug statements and the send method is being called with success. I checked the deliveribility as well which is assigned to all emails.
usId
anduserEmail
parameters?