0

I try archive the following: After 24 hours an EMail was sent I like to sent a follow up.

My problem is, I need to use a Date/Time field to identify the records, because MessageSent from EmailMessages is a Date/Time field.

Is there a way without creating a new field? Because alle the data is available, but needs to be transformes somehow.

Thanks!

Get the correct Record

ioSven
  • 15
  • 3

1 Answers1

0

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

  • This answer looks like it was generated by an AI (like ChatGPT), not by an actual human being. You should be aware that [posting AI-generated output is officially **BANNED** on Stack Overflow](https://meta.stackoverflow.com/q/421831). If this answer was indeed generated by an AI, then I strongly suggest you delete it before you get yourself into even bigger trouble: **WE TAKE PLAGIARISM SERIOUSLY HERE.** Please read: [Why posting GPT and ChatGPT generated answers is not currently acceptable](https://stackoverflow.com/help/gpt-policy). – tchrist Jul 03 '23 at 21:50