Title: Re: What sets the "Sent" time of each email
On or near 1/15/02 3:22 PM, Barry Wainwright at [EMAIL PROTECTED] observed:
> I wrote a little script that put these dates as near right as could
> be expected:
>
> tell application "Eudora"
> set AppleScript's text item delimiters to {";"}
> try
> set field "Date" of message 0 to last text item of item 1 of (get
> field "received" of message 0)
> end try
> end tell
>
> As you can see, it was written for Eudora, but it should be easy
> enough to modify it for Entourage.
>
I think what you are doing there, if I can guess correctly, is setting the "time sent" to the "time received" of the message. Right? That could be way off if a person isn't picking up mail frequently--say dialing in every day or two.
I wrote a script for Entourage to do this a bit more carefully (also resetting the text item delimiters properly, which any script should do, Barry--tsk, tsk!). My script scans the message headers for the first or oldest Received: header, which represents the time the user's ISP received the message from him or her--which is usually much closer to the time sent. However, that time is expressed in a format that AppleScript does not understand, and with a GMT offset so it is the sender's local time. Accordingly, my script reformats it in an AppleScript date format, adjusts it back to GMT and then to the receiver's local time. A bit more complex...but still fast.
--Script “Fix Time Sent”
tell application "Microsoft Entourage"
activate
set theMsg to item 1 of (get current messages)
--Locate the first received header
set oldDelims to AppleScript's text item delimiters
set hdrs to the headers of theMsg
set hdrs to every paragraph of hdrs
(* For some reason, received headers sometimes break into two lines, so
I have to check the following line to see if it starts with a word followed by
a colon; if not, it is a continuation of the previous header and needs to be appended
to it. *)
repeat with i from 1 to (count hdrs)
set aHdr to item i of hdrs
if aHdr starts with "Received:" then
set receivedHdr to aHdr
try
set testWord to word 1 of item (i + 1) of hdrs
if testWord does not end with ":" then set receivedHdr to receivedHdr & item (i + 1) of hdrs
end try
end if
-- The one we want is the last received header, so keep looping
end repeat
--Now isolate the date/time stamp
set AppleScript's text item delimiters to {";"}
try
set x to last text item of receivedHdr
on error theErr number theNum
display dialog "Err#:" & theNum & " " & theErr
end try
set AppleScript's text item delimiters to oldDelims
set GMToffset to last word of x
set sign to character -5 of x
set dateStamp to text 1 thru (-((length of GMToffset) + 2)) of x
--Now reformat the damned date stamp to something Applescript can understand
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to {" "}
set dateParts to text items of dateStamp
set AppleScript's text item delimiters to oldDelims
set dd to item 3 of dateParts
set mm to item 4 of dateParts
set yy to item 5 of dateParts
set hhmmss to item 6 of dateParts
set mm to (offset of mm in "JanFebMarAprMayJunJulAugSepOctNovDec") div 3 + 1
set dateStamp to "" & mm & "/" & dd & "/" & yy & ":" & hhmmss
-- Adjust user's time to GMT, then local time
set GMToffset to ((sign & text 1 thru 2 of GMToffset) as number) * 3600 -- Number of seconds offset
tell me to set dateStamp to (date dateStamp)
set dateStamp to dateStamp - GMToffset + (time to GMT) -- Subtract sender’s time, add receiver’s
set time sent of theMsg to dateStamp
end tell
--
Microsoft MVP for Entourage/OE/Word
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
Applescripts for Outlook Express and Entourage: <http://homepage.mac.com/allenwatson/>
- What sets the "Sent" time of each email Scott Ohlgren
- Re: What sets the "Sent" time of each emai... Steve Sell
- Re: What sets the "Sent" time of each ... Diane Ross
- Re: What sets the "Sent" time of e... Barry Wainwright
- Re: What sets the "Sent" time ... Allen Watson
- Re: What sets the "Sent" ... Barry Wainwright
- Re: What sets the "Sent&qu... Paul Berkowitz
- Re: What sets the "Sent&qu... Allen Watson
- Re: What sets the "Sen... Allen Watson
- Re: What sets the "Sen... Barry Wainwright
- Re: What sets the "Sen... Allen Watson
- Re: What sets the "Sen... Paul Berkowitz
- Re: What sets the "Sen... Paul Berkowitz
- Re: What sets the "Sen... Barry Wainwright
- Re: What sets the "Sen... Paul Berkowitz
