You need to sign in to do that
Don't have an account?

Invalid type: UtilException
this is my class code..
And getting this error
plz help...
thnx
public with sharing class SendTemplatedEmail{
public static void sendTemplatedEmail(String[] toRecipients, String[] ccRecipients,
String templateApiName, ID targetObjId, Id whatId, ID orgWideEmailId,
Boolean saveAsActivity, Attachment[] attachList )
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Id templateId;
try {templateId = [select id, name from EmailTemplate where developername = : templateApiName].id;}
catch (Exception e) {
throw new UtilException ('[U-03] Unable to locate EmailTemplate using name: ' + templateApiName +
' refer to Setup | Communications Templates ' + templateApiName);
}
email.setToAddresses(toRecipients);
email.setCcAddresses(ccRecipients);
email.setTargetObjectId(targetObjId);
email.setWhatId(whatId);
email.setorgWideEmailAddressId(orgWideEmailId);
email.setTemplateId(templateId);
email.setSaveAsActivity(saveAsActivity);
System.debug(LoggingLevel.INFO,'** entered sendTemplatedEmail, to:' + toRecipients + ' cc:' + ccRecipients + ' templateId:' + templateId + ' tagetObjId:' + targetObjId +
' whatId:' + whatId + ' orgWideEmailId: ' + orgWideEmailId);
try {
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
return;
}
catch (EmailException e) {throw new UtilException('[U-02] sendTemplatedEmail error. ' + e.getMessage());}
}
}
And getting this error
plz help...
thnx
public with sharing class SendTemplatedEmail{
public static void sendTemplatedEmail(String[] toRecipients, String[] ccRecipients,
String templateApiName, ID targetObjId, Id whatId, ID orgWideEmailId,
Boolean saveAsActivity, Attachment[] attachList )
{
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
Id templateId;
try {templateId = [select id, name from EmailTemplate where developername = : templateApiName].id;}
catch (Exception e) {
throw new UtilException ('[U-03] Unable to locate EmailTemplate using name: ' + templateApiName +
' refer to Setup | Communications Templates ' + templateApiName);
}
email.setToAddresses(toRecipients);
email.setCcAddresses(ccRecipients);
email.setTargetObjectId(targetObjId);
email.setWhatId(whatId);
email.setorgWideEmailAddressId(orgWideEmailId);
email.setTemplateId(templateId);
email.setSaveAsActivity(saveAsActivity);
System.debug(LoggingLevel.INFO,'** entered sendTemplatedEmail, to:' + toRecipients + ' cc:' + ccRecipients + ' templateId:' + templateId + ' tagetObjId:' + targetObjId +
' whatId:' + whatId + ' orgWideEmailId: ' + orgWideEmailId);
try {
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
return;
}
catch (EmailException e) {throw new UtilException('[U-02] sendTemplatedEmail error. ' + e.getMessage());}
}
}
This error suggests that you haven't defined the custom class 'UtilException' - is it available in your codebase?