Copy Mac Mail Message Contents To Clipboard?

It doesn’t matter how you name the variable. The important things is to set it.

You can do it in an analogous way as the theDate variable is set in line 20 of the script:

set theDate to date string of (get date received of theMsg)

So, add this:

set theTime to time string of (get date received of theMsg)

And then —the same as with the date— add the theTime variable to the theHeader variable, which will produce the output (line 52, marked with “# Compose the header” in the script).

For example, to add the time at the end:

set theHeader to "From: " & theSender & linefeed & "To: " & toRecipients & linefeed & "CC: " & ccRecipients & linefeed & "BCC: " & bccRecipients & linefeed & "Subject: " & theSubject & linefeed & "Date received: " & theDate & linefeed & "Time received: " & theTime

This will produce a header like this (example):

From: xxx xxx xxx.xxx@xxx.xxx
To: bbedit@googlegroups.com
CC:
BCC:
Subject: Manipulating buffer in window with AppleScript?
Date received: Wednesday, 12. April 2017
Time received: 00:38:45‌


Or, if you prefer to have date and time in one line:

set theHeader to "From: " & theSender & linefeed & "To: " & toRecipients & linefeed & "CC: " & ccRecipients & linefeed & "BCC: " & bccRecipients & linefeed & "Subject: " & theSubject & linefeed & "Received: " & theDate & "; " & theTime

which will produce this:

From: xxx xxx xxx.xxx@xxx.xxx
To: bbedit@googlegroups.com
CC:
BCC:
Subject: Manipulating buffer in window with AppleScript?
Received: Wednesday, 12. April 2017; 00:38:45