Yes, you can achieve this without creating a new field by using SOQL (Salesforce Object Query Language). You can use the DATEDIFF
and NOW
functions to filter out the records based on the difference in time between the current date and the MessageSent
field.
Here's a sample query that retrieves EmailMessage records that were sent exactly 24 hours ago:
SELECT Id, Subject, MessageSent, ToAddress
FROM EmailMessage
WHERE DATEDIFF('hour', MessageSent, NOW()) = 24
This query will return the EmailMessage records where the difference between the MessageSent
field and the current time is exactly 24 hours.
You can then use this information to send a follow-up email programmatically by iterating over the returned records and sending an email through Apex code or Process Builder.
Hope it helps