You need to sign in to do that
Don't have an account?
cant create the case via customer portal
Hi,
I have enabled the customer portal and configured it.
I also created the trigger which sends the notification when the case is created either via email or customer portal.
The following is my trigger code,
trigger mailNotification on Case ( after insert) { contact CaseContact; for(case Cases :trigger.new){ //Fetch the related case contact. Messaging.SingleEmailMessage CaseNotificationmail = new Messaging.SingleEmailMessage (); if (CaseContact!= null){ CaseContact = [SELECT Email FROM Contact WHERE Id = :Cases.ContactId]; if (CaseContact != null && CaseContact.Email != null) { CaseNotificationmail.setToAddresses(new List<string> {CaseContact.Email}); } } else { CaseNotificationmail.setToAddresses(new List<string> {Cases.SuppliedEmail}); } CaseNotificationmail.setReplyTo('createcases@i- 1byw7u3dtfg21ai2tii0rpnf6q345ovsuuelzkgmta35336rgt.9-mqfdeae.9.apex.salesforce.com'); CaseNotificationmail.setSenderDisplayName('Salesforce Support'); CaseNotificationmail.setSubject('New Case Created : ' + Cases.CaseNumber); CaseNotificationmail.setPlainTextBody('Your case:<b> ' + Cases.CaseNumber +' has been created.'+'To view your case <a href=https://na1.salesforce.com/'+case.Id); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { CaseNotificationmail }); } }
When I used this trigger, I cant create the new case by customer portal.
It shows the following error
"
Error: Invalid Data.
Review all error messages below to correct your data.
Apex trigger mailNotification caused an unexpected exception, contact your administrator: mailNotification: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Invalid to address : null: []: Trigger.mailNotification: line 20, column 1"
If i am using workflow rules , I will not include the sepecified address for reply.
Can anybody help to solve this problem?
Regards.,
Ambiga
Hi Ambiga,
The error seems to point that the email address is not being identified - I checked the following doc wheich shows replyto email in double quotes - http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_sendemail.htm
Could you try this and let me knwo if that helps..
Hi AmbigaRam,
After looking at the exception you got, I believe you should add null check contion at below snippet of code
Thanks,
Ganesh