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
Nandhini S 3Nandhini S 3 

Is it possible to capture automated email notifications?

Hi All,

I have 'Case created' & 'Case Closed' email notifications which are sent from a flow. I have a requirement to capture these notification emails in the chatter feed. Right now, Only if the user responds on top of the automated notifications, it's captured in chatter feed.
Shri RajShri Raj
Yes, it is possible to capture automated email notifications in the Chatter feed. One way to achieve this is to use the Email-to-Case feature. You can set up an Email-to-Case address and configure your flow to send the notifications to that address. When the notifications are received, Salesforce will automatically create a Case and associate it with the relevant Contact or Lead, depending on your configuration. The Case can be monitored and commented on in the Chatter feed, allowing you to capture the notifications in the Chatter feed.

Also a trigger example
 
trigger CaseTrigger on Case (after insert, after update) {
    for (Case c : Trigger.new) {
        // Check if the Case was just created
        if (Trigger.isInsert && c.Status == 'New') {
            ConnectApi.ChatterFeeds.postFeedItem(null, ConnectApi.FeedType.Record, c.Id, null, null);
        }
        // Check if the Case was just closed
        if (Trigger.isUpdate && c.Status == 'Closed' && Trigger.oldMap.get(c.Id).Status != 'Closed') {
            ConnectApi.ChatterFeeds.postFeedItem(null, ConnectApi.FeedType.Record, c.Id, null, null);
        }
    }
}


In this example, the trigger uses the ConnectApi.ChatterFeeds.postFeedItem method to post a Chatter feed item. The first parameter is the community ID, which is set to null in this example, indicating that the Chatter feed item should be posted to the standard Chatter feed. The second parameter is the feed type, which is set to ConnectApi.FeedType.Record to indicate that the feed item is associated with a specific record. The third parameter is the record ID, which is set to the ID of the Case. The fourth and fifth parameters are not used in this example.