
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-16-2023 10:04 AM
Hey everyone,
Is it possible to insert a new email record into the 'sys_email' table, and use this new record for testing inbound email actions instead of emailing an instance directly? My use case is that it would be faster than waiting for emails to process (especially those forwarded over from other inboxes), and it could be easily adapted to allow for testing from multiple email addresses.
I've attempted to try this out using a background script, and I've been able to insert a new email record that has a Type, User ID, Subject, Recipient, Body, etc. The record is created successfully, however no inbound rules are run, and the Email Log related list remains empty. I'm not sure if the Content type / Headers fields would also need to be populated to get the Inbound Actions to run properly.
If anyone has done this before, or could let me know if this is/isn't possible, that would be great!
Thank you for your time,
Jack
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 12:56 AM
Hi @Community Alums ,
It is possible to manually insert a new email record into the 'sys_email' table for testing purposes. However, to trigger inbound email actions and populate the Email Log related list, you would need to populate additional fields beyond the standard email fields such as the content type and headers.
Here are some steps you could take to create a new email record for testing inbound email actions:
Create a new record in the 'sys_email' table and populate the standard email fields such as Type, User ID, Subject, Recipient, Body, etc.
Populate the 'headers' field with the appropriate email headers for the email you want to simulate. You can find these headers by inspecting the email source code or using a tool like Postman to capture the headers from a real email.
Populate the 'content_type' field with the appropriate content type for the email you want to simulate. This should match the content type specified in the email headers.
Ensure that the 'state' field is set to 'received' and that the 'received_on' field is set to the current date and time.
Save the record and verify that the inbound email actions are triggered and the Email Log related list is populated.
Keep in mind that testing inbound email actions with manually inserted email records may not provide a completely accurate representation of how the system will handle real incoming emails. However, it can be a useful tool for initial testing and troubleshooting.
If my response helps you to resolve the issue close the question by ✅Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-17-2023 12:56 AM
Hi @Community Alums ,
It is possible to manually insert a new email record into the 'sys_email' table for testing purposes. However, to trigger inbound email actions and populate the Email Log related list, you would need to populate additional fields beyond the standard email fields such as the content type and headers.
Here are some steps you could take to create a new email record for testing inbound email actions:
Create a new record in the 'sys_email' table and populate the standard email fields such as Type, User ID, Subject, Recipient, Body, etc.
Populate the 'headers' field with the appropriate email headers for the email you want to simulate. You can find these headers by inspecting the email source code or using a tool like Postman to capture the headers from a real email.
Populate the 'content_type' field with the appropriate content type for the email you want to simulate. This should match the content type specified in the email headers.
Ensure that the 'state' field is set to 'received' and that the 'received_on' field is set to the current date and time.
Save the record and verify that the inbound email actions are triggered and the Email Log related list is populated.
Keep in mind that testing inbound email actions with manually inserted email records may not provide a completely accurate representation of how the system will handle real incoming emails. However, it can be a useful tool for initial testing and troubleshooting.
If my response helps you to resolve the issue close the question by ✅Accepting solution and hit 👍thumb icon. From Correct answers others will get benefited in future.
Thanks,
Ratnakar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2023 07:00 AM
I tried but didnt helped.
The records are created with some values in standard field but the inbound email action doesnt run
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-31-2024 02:53 PM
Hi,
Did you ever end up figuring this out? I can never trigger an inbound action if I script a way to insert a 'received' email in the sys_email table. Clicking 'reprocess email' would fire off email logs but then the inbound action doesn't run as the system logs say 'did not create or update using current'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 03:43 AM
I had the same issue and found that you need to also insert the event for this to be handled by the system. I used the below code:
var evt = new GlideRecord('sysevent');
evt.initialize();
evt.user_id = USERID;
evt.user_name = LOGING;
evt.process_on = gs.nowDateTime();
evt.name = "email.read";
evt.parm1 = id;
evt.insert();
if (email.type == "received-ignored") {
email.type = "received";
email.update();
}
The UserID and Login correspond to the IDs of the user you mimic sends the email. You can programatically pick these up or hard code them depending on your needs. The setting of the email GR to received is also needed for some reason - but it does the trick.