You can simulate error in send Email by using one of the following approaches -
1. Populate incorrect, incomplete data in SingleEmailMessage instance
Note - All email must have a recipient value of at least one of the following: • toAddresses • ccAddresses • bccAddresses • targetObjectId • targetObjectIds
For test purpose, don't specify any of the above attributes of SingleEmailMessage object.
Now run the code and sendEmail should fail with an error.
2. Governor limits on Send Mail invocation
you can only call sendMail 10 times within Apex code. For test purpose, you can make your code call sendEmail more than 10 times.
You can simulate error in send Email by using one of the following approaches -
1. Populate incorrect, incomplete data in SingleEmailMessage instance
Note - All email must have a recipient value of at least one of the following: • toAddresses • ccAddresses • bccAddresses • targetObjectId • targetObjectIds
For test purpose, don't specify any of the above attributes of SingleEmailMessage object.
Now run the code and sendEmail should fail with an error.
2. Governor limits on Send Mail invocation
you can only call sendMail 10 times within Apex code. For test purpose, you can make your code call sendEmail more than 10 times.
Hi,
You can simulate error in send Email by using one of the following approaches -
1. Populate incorrect, incomplete data in SingleEmailMessage instance
Note - All email must have a recipient value of at least one of the following:
• toAddresses
• ccAddresses
• bccAddresses
• targetObjectId
• targetObjectIds
For test purpose, don't specify any of the above attributes of SingleEmailMessage object.
Now run the code and sendEmail should fail with an error.
2. Governor limits on Send Mail invocation
you can only call sendMail 10 times within Apex code. For test purpose, you can make your code call sendEmail more than 10 times.
All Answers
For your own custom messages, use message classes :
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Invalid mail');
ApexPages.addMessage(myMsg);
and put this component <apex:pagemesseges> in VF Page.
Did this answer your question? if so, please mark it solved.
thnak you for reply
and
Sorry for non clear-cut explanation
I wrote
But, I have no idea how to be error situation.
Hi,
You can simulate error in send Email by using one of the following approaches -
1. Populate incorrect, incomplete data in SingleEmailMessage instance
Note - All email must have a recipient value of at least one of the following:
• toAddresses
• ccAddresses
• bccAddresses
• targetObjectId
• targetObjectIds
For test purpose, don't specify any of the above attributes of SingleEmailMessage object.
Now run the code and sendEmail should fail with an error.
2. Governor limits on Send Mail invocation
you can only call sendMail 10 times within Apex code. For test purpose, you can make your code call sendEmail more than 10 times.
Thank you for reply
I can get error
Satgur, thank you very much.