+ Start a Discussion
Justin LonisJustin Lonis 

can anyone help me create a trigger to get email notifications from feed comments?

Looking to get an email notification when a customer in our community comments on a "TEXT POST" feed comment. I'm not sure how to accomplish this or where to start. 
Best Answer chosen by Justin Lonis
Sunil MadanaSunil Madana
i created the trigger on "FeedComment" object. So whenever there is a comment added for a feed, you will receive an email alert.
trigger myFeedcomment on FeedComment (after insert) {
    String[] emailAdd;
	// Send Email to the requestor about user creation.
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    // Assign the addresses for the To and CC lists to the mail object.    
    emailAdd = new String[] { 'youremailaddress' };
    // Specify the address used when the recipients reply to the email. 
    // Specify the name used as the display name.
    mail.setSenderDisplayName('Salesforce CRM');
    // Specify the subject line for your email address.
    mail.setSubject('A New Comment has been added: ');
    // Set to True if you want to BCC yourself on the email.
    // Specify the text content of the email.
    mail.setPlainTextBody('New Comment has been created');
    mail.setHtmlBody('New Comment has been created');
    // Send the email you have created.
    Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

If the above suggestion worked, let us know by marking the answer as "Best Answer" right under the comment which will help the rest of the community should they have a similar issue in the future. Thanks, Sunil