You need to sign in to do that
Don't have an account?
Opportunity Team Notification
With the Winter '13 release of Salesforce, they have added native trigger support for Opportunity Teams (previously Selling Teams). We would like to have our users notified when they are added to a Opportunity Team. I have written the code below.
trigger EmailTeamMember2 on OpportunityTeamMember (after insert) { Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); for (OpportunityTeamMember o : trigger.new) { String[] toAddresses = new String[] {o.User.email}; mail.setToAddresses(toAddresses); mail.setReplyTo ('support@acme.com'); mail.setSenderDisplayname('Salesforce Support'); mail.setSubject('Added to an Opportunity Team : '); mail.setUseSignature(false); mail.setPlainTextBody('You have been added to the Opportunity Team of: ' + o.Opportunity); mail.setHtmlBody('You have been added to the Opportunity Team of:<b> '+ o.Opportunity+'); Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail }); } }
It saves without any errors, but when I try to add a team member this error appears:
Apex trigger EmailTeamMember2 caused an unexpected exception, contact your administrator: EmailTeamMember2: execution of AfterInsert caused by: System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Invalid to address : null: []: Trigger.EmailTeamMember2: line 16, column 1
Thanks for your help in advance!!! :)
I was able to get the code working below for our instance. It does a very simple email, but it works for our purposes.
All Answers
Hi cambart, did you figure this out? I'm looking to do the same thing. Thanks!
I was able to get the code working below for our instance. It does a very simple email, but it works for our purposes.