Accessing Email Record from Inbound Email Actions
gs.eventQueue("sys_email.u.mail_integration.max.records.exceeded", sys_email, null, null);
The trick is the "sys_email" variable - it is actually a record of the email the Inbound Email Action is working on. It is not currently documented in the Inbound Email Action wiki article, but I found it buried in some release notes for the Spring 2009 release - http://wiki.servicenow.com/index.php?title=Spring\_2009\_Notable\_Changes#New\_.22sys\_email.22\_global\_variable\_available\_to\_Inbound\_Email\_Actions.
So by including it in the eventQueue call and configuring the notification on the "Email [sys_email]" table, the event is tied to the email record and we can access the record with "current" in some mail_script within the message of the notification:
An email has been received which exceeds the number of expected records.
<mail_script>
var url = gs.getProperty("glide.servlet.uri") + "nav_to.do?uri=sys_email.do?sys_id=" + current.getValue("sys_id") + "%26sysparm_view=inbox";
template.print("<a href='" + url + "'>Click this link to view the email.</a>");
</mail_script>
And the result is the following:
https://www.servicenow.com/community/in-other-news/accessing-email-record-from-inbound-email-actions/ba-p/2290845