You need to sign in to do that
Don't have an account?
MsKnight
Test Method for Outbound Email
Hi,
I'm trying to write a Test Method for a class that sends an email. I'm stuck at 73% - I can cover the addRoofMountsCheck, but can't get coverage on lines 8-18 (all of the code for sending the email). Any suggestions?
Thanks!
I'm trying to write a Test Method for a class that sends an email. I'm stuck at 73% - I can cover the addRoofMountsCheck, but can't get coverage on lines 8-18 (all of the code for sending the email). Any suggestions?
Code:
public class RoofMountsIn { public static void addRoofMountsCheck(SFDC_Project__c[] pros) { for (SFDC_Project__c p:pros) { if (p.Roof_Mounts_In__c != True){ p.Roof_Mounts_In__c = True; for (User user : [SELECT Email FROM user WHERE UserRoleId = 'userId']){ Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); String[] toAddresses = new String[] {user.Email}; mail.setToAddresses(toAddresses); mail.setSaveAsActivity(false); mail.setTargetObjectId('contactId'); mail.setWhatId(p.Id); mail.setTemplateID('emailtemplateId'); // Send the email you have created. Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } } } } }
Thanks!
for instance, I do the same thing you are in all of my classes to debug via email vs. debugging through their interface, and to do so I created a seperate class to handle all outbound single emails.
I have lots of SControl email related example but I am not able to make them work , such that it simply opens the email SF window . The code that I have tried, successfully sends the e-mail but is not able to open th eSF Email window.
Can you give me an example to use SendEmail with their parameters through URLFOR ( I am not able to make it work].
Thanks
Regards
here's an example I use to go straight from a case, select a specific email template, and prepopulate some of the field with the value of a custom field on the case.
this is the code for a custom button.
But does this mean it's not possible to achieve this via URLFor Method (something in the lines of URLFor($Action.Activity.SendEmail) ) ?
Thanks. I really appreciate your respond .