function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ 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
hi
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.reserveSingleEmailCapacity(2);
    Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
    
    // Assign the addresses for the To and CC lists to the mail object.    
    emailAdd = new String[] { 'youremailaddress' };
    mail.setToAddresses(emailAdd);
    
    // Specify the address used when the recipients reply to the email. 
    mail.setReplyTo('support@salesforce.com');
    
    // 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.
    mail.setBccSender(true);
    
    // 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