Skip to content

Instantly share code, notes, and snippets.

@icerge
Last active October 11, 2018 22:05
Show Gist options
  • Save icerge/7f5a139e217056f7469ffee999fbd1a5 to your computer and use it in GitHub Desktop.
Save icerge/7f5a139e217056f7469ffee999fbd1a5 to your computer and use it in GitHub Desktop.
Sample code to get Thread-Topic header (email conversation topic) from inbound email.

Thread-Topic is a header of email message, it contains the original subject of the conversation

var headers = email.headers + "";
var topic_regex = /Thread-Topic:(.*)/i;
var topic_match = topic_regex.exec(headers);
var topic = (topic_match && topic_match[1]) ? topic_match[1] : email.subject;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment