Test 1 using Outlook 2016 or 2019
What we are doing is creating a test message and saving as eml file. When this file is opened and then replied to using the script the original sent date in the header that now shows in message body gets changed to the current date/time. This only happens in Outlook 2016 and 2019. Outlook 2011 keeps the original date and time.
Test 1 using Outlook 2016 or 2019
- Create a simple email in Outlook with subject as test, body as test, and to address to yourself.
- Send the message, if used yourself the message should come into your inbox as a new message.
- Open the message and take note of the sent date/time.
- Export the new email to the /Users/Shared folder. Should be called test.eml
- Wait for some time to go by like 5 minutes. If you open the eml file in Outlook you will see the date and time from when sent from earlier time.
- Open Script Editor
- Copy and paste the following script into the editor:
set theFile to (POSIX file "/Users/Shared/test.eml")
open for access theFile
set fileContents to (read theFile)
close access theFile
tell application "/Applications/Microsoft Outlook.app"
set SelectedMessages to current messages
repeat with theMsg in SelectedMessages
set msgID to id of theMsg
set theAccount to account of the message id msgID
set theSender to sender of the message id msgID
set theDt to time received of the message id msgID
set theMsg to make new incoming message at (deleted items of theAccount) with properties {sender:theSender, source:fileContents, account:theAccount}
set replyWindow to reply to theMsg
permanently delete theMsg
exit repeat
end repeat
end tell
- Now when you compile and run the Applescript it will open the eml file and create a new reply message in window but the date in the header of the original message is changed to the current date and time. This date should remain as the original sent date. What changes can I make to this script to make it work properly?
Test 2 using Outlook 2011
- Create a simple email in Outlook with subject as test, body as test, and to address to yourself.
- Send the message, if used yourself the message should come into your inbox as a new message.
- Open the message and take note of the sent date/time.
- Export the new email to the /Users/Shared folder. Should be called test.eml
- Wait for some time to go by like 5 minutes. If you open the eml file in Outlook you will see the date and time from when sent from earlier time.
- Open Script Editor
- Copy and paste the following script into the editor:
set theFile to (POSIX file "/Users/Shared/test.eml")
open for access theFile
set fileContents to (read theFile)
close access theFile
tell application "/Applications/Microsoft Office 2011/Microsoft Outlook.app"
set SelectedMessages to current messages
repeat with theMsg in SelectedMessages
set msgID to id of theMsg
set theAccount to account of the message id msgID
set theSender to sender of the message id msgID
set theDt to time received of the message id msgID
set theMsg to make new incoming message at (deleted items of theAccount) with properties {sender:theSender, source:fileContents, account:theAccount}
set replyWindow to reply to theMsg
permanently delete theMsg
exit repeat
end repeat
end tell
- Now when you compile and run the Applescript it will open the eml file and create a new reply message in window but the date in the header of the original message is as expected with the older date and time shown.
I would like to keep the Applescript code above as similar as possible, however if there is a better way of doing this then maybe time to change as needed. The difference in behavior was changed in 2016. Is there any minor changes I can make to my current Applescript code to keep the original date and time? Can someone explain to me why this behavior changed? Thanks in advance to anyone who can help with this.