You need to sign in to do that
Don't have an account?
randombard
Send Email if chatter body contains #Tech
Hi All,
Trying to work out how to achieve this, so far I have the following but nothing appears to happen.
please note where is states emailfgoeshere I usually place an email address, just not in this example. :-)
trigger IncludeTechnicalSuppoer on FeedItem (before insert) { String oppKeyPrefix = Opportunity.sObjectType.getDescribe().getKeyPrefix(); for (FeedItem f: trigger.new) { String parentId = f.parentId; //We compare the start of the 'parentID' field to the Opportunity key prefix to //restrict the trigger to act on posts made to the Opportunity object. if (parentId.startsWith(oppKeyPrefix) && f.Body == '#Tech') { //Send message to technical support String[] toaddress = new String[]{}; toaddress.add('emailgoeshere'); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); mail.setToAddresses(toaddress); mail.setsubject('TechnicalMessage'); mail.saveAsActivity = false; } } }
First question what do I need to do to make this actually send and second question should I really be using a template to send richer content?
Thanks
R
You are missing sendEmail method in your code which is required to send mails.
Please put below code after mail.saveActivity=false;
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
and it would work.
All Answers
You are missing sendEmail method in your code which is required to send mails.
Please put below code after mail.saveActivity=false;
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
and it would work.
That's brilliant thanks