How to Correct Date Stamp

A

aRKay

I received a message on 13-Mar-05 from an Outlook user who may have had
his PC clock hosed. I view my Inbox by date from the most recent at the
top and the 28-Mar (future) message is always at the top

-----------
Date: Mon, 28 Mar 2005 10:39:53 -0500
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.2180
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
-----------

I tired to use the Mac Entourage 2004 Edit Message command but it will
not let me change the date. When I try to change the date it deletes
the message. I opened it as source file but then the Edit Message
option was not active.

Help...... Can the date on a hosed message be corrected?

aRKay
 
B

Barry Wainwright

I received a message on 13-Mar-05 from an Outlook user who may have had
his PC clock hosed. I view my Inbox by date from the most recent at the
top and the 28-Mar (future) message is always at the top

-----------
Date: Mon, 28 Mar 2005 10:39:53 -0500
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 6.00.2900.2180
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
X-RFC2646: Format=Flowed; Original
-----------

I tired to use the Mac Entourage 2004 Edit Message command but it will
not let me change the date. When I try to change the date it deletes
the message. I opened it as source file but then the Edit Message
option was not active.

Help...... Can the date on a hosed message be corrected?

aRKay

Use my 'Correct the Date' script, which was written for just this task.
Copy/paste from below, but watch out for false line-wraps:



-- Correct the date v1.0 25th June 2002
-- a script for Microsoft Entourage by Barry Wainwright
-- Resets the date of messages to the date of the first received header
-- useful for messages with badly formatted (or just plain wrong) dates

tell application "Microsoft Entourage"
set theMessages to current messages
if theMessages is {} then
display dialog "No messages selected!" buttons {"Stop"} default
button 1 with icon stop
return -99
end if

repeat with theMess in theMessages
set theHeaders to the headers of theMess
set AppleScript's text item delimiters to {return & space}
set theHeaders to text items of theHeaders
set AppleScript's text item delimiters to {space}
set theHeaders to theHeaders as string
set AppleScript's text item delimiters to {return & tab}
set theHeaders to text items of theHeaders
set AppleScript's text item delimiters to {space}
set theHeaders to theHeaders as string
set theHeaders to the paragraphs of theHeaders
set receivedHeader to ""
repeat with aHeader in theHeaders
if aHeader starts with "Received:" then copy contents of aHeader
to receivedHeader
end repeat
set AppleScript's text item delimiters to {";"}
set theDate to (last text item of receivedHeader)
set time sent of theMess to date theDate
end repeat
end tell
 
A

aRKay

Barry Wainwright said:
Use my 'Correct the Date' script, which was written for just this task.
Copy/paste from below, but watch out for false line-wraps:



-- Correct the date v1.0 25th June 2002
-- a script for Microsoft Entourage by Barry Wainwright
-- Resets the date of messages to the date of the first received header
-- useful for messages with badly formatted (or just plain wrong) dates

tell application "Microsoft Entourage"
set theMessages to current messages
if theMessages is {} then
display dialog "No messages selected!" buttons {"Stop"} default
button 1 with icon stop
return -99
end if

repeat with theMess in theMessages
set theHeaders to the headers of theMess
set AppleScript's text item delimiters to {return & space}
set theHeaders to text items of theHeaders
set AppleScript's text item delimiters to {space}
set theHeaders to theHeaders as string
set AppleScript's text item delimiters to {return & tab}
set theHeaders to text items of theHeaders
set AppleScript's text item delimiters to {space}
set theHeaders to theHeaders as string
set theHeaders to the paragraphs of theHeaders
set receivedHeader to ""
repeat with aHeader in theHeaders
if aHeader starts with "Received:" then copy contents of aHeader
to receivedHeader
end repeat
set AppleScript's text item delimiters to {";"}
set theDate to (last text item of receivedHeader)
set time sent of theMess to date theDate
end repeat
end tell

Thanks! it worked PERFECT. Really a nice script.

dick
 
G

gg

The script corrects most of my munged mail... but there are some
problems:

The first - the time picked up is that in the last received header,
which is generally the time that the mail hit the first MTA. This is
great if the broken part of the date is the sent time, but in my case
the sent time was fine - the received time was b0rked. When Entourage
crashes with the imap server connected (dovecot 0.99.11), it begins
re-receiving all of the email but uses the current time as the received
time. Oddly enough, this became evident after a number of crashes of
the script on a large group of emails. Examination of the event log led
to the identification of an apparent flaw in the script:

The header of a typical email that caused a crash, munged for privacy:

Received: from pu.ogauud.com (ns.ogauud.com [x.x.x.x])
by ogud.com (8.12.11/8.12.11) with ESMTP id j2AGv5qW008089;
Thu, 10 Mar 2005 11:57:05 -0500 (EST)
(envelope-from [email protected])

resulting in:

"Invalid date and time Thu, 10 Mar 2005 11:57:05 -0500 (EST)
(envelope-from [email protected])."

Another:

Received: by mailagent1.ientrymail.com (PowerMTA(TM) v2.0r1) id
h5hp7m03us84; Mon, 7 Mar 2005 10:25:47 -0500 (envelope-from
<[email protected]>)

Resulting in:

"Invalid date and time Mon, 7 Mar 2005 10:25:47 -0500 (envelope-from
<[email protected]>)."

Examining the emails themselves showed clearly that the script was
looking at the last instance of the Received header (correctly
obviously, according to Barry's 1.0 script), which is generally the
first MTA the email hit on it's way out - so more likely the sent
time, and not the received time in my system. And of course, the odd
data appended to the headers were the result of non-standard
configuration of the sending MTA. While my inbound SMTP imap server may
also be misconfigured, at least it will be consistent ;-). And
naturally it will have the correct received time. Sort of (more later).


So I solved both problems by modifying:

repeat with aHeader in theHeaders
if aHeader starts with "Received:" then copy contents of
aHeader to receivedHeader
end repeat

with

repeat with aHeader in theHeaders
if aHeader starts with "Received:" then copy contents of
aHeader to receivedHeader
if contents of receivedHeader is not "" then exit repeat
end repeat

That results in the first Received header time being picked up. OK, all
consistent with Barry.

The next problem (which highlighted a more significant issue) is that
the script fails when it hits a timestamp that includes that odd
appendix (envelope-from [email protected]). I solved that by modifying:

set AppleScript's text item delimiters to {";"}
set theDate to (last text item of receivedHeader)
set time received of theMess to date theDate

to

set AppleScript's text item delimiters to {";", "("}
set theDate to (last text item of receivedHeader)
set time received of theMess to date theDate

However, it became evident that for some reason the script is not able
to deal with timezones in the time stamp. So:

Received: from mail pickup service by smtp1.bellevue.com with Microsoft
SMTPSVC;
Thu, 7 Apr 2005 12:18:27 -0000 (UTC)

results in the time being corrected to 12:18:27 rather than 05:18:27
which is correct for my local timezone. I am unable to find any
references in the Apple Scripting man pages to indicate a mechanism to
handle timestamps that include an offset. My imap server is set to UTC
so all timestamps show -0000 (UTC).

In any case, the script solved almost all the problems, and at least
brought the time stamps within range (+7 hours) ;-)). Thanks!
 
A

Alastair Clarke

Hi,

I hope someone can help me. Entourage just downloaded all my emails (about
2000) from the server - emails from December that I had already retrieved on
my computer. Why did it do that?!

It's the second or third time it's happened. I have to then organize by
unread - and delete all the emails it just got (and screen the ones that are
from the last 10mins).

Any ideas?

Cheers,
Alastair

The script corrects most of my munged mail... but there are some
problems:

The first - the time picked up is that in the last received header,
which is generally the time that the mail hit the first MTA. This is
great if the broken part of the date is the sent time, but in my case
the sent time was fine - the received time was b0rked. When Entourage
crashes with the imap server connected (dovecot 0.99.11), it begins
re-receiving all of the email but uses the current time as the received
time. Oddly enough, this became evident after a number of crashes of
the script on a large group of emails. Examination of the event log led
to the identification of an apparent flaw in the script:

The header of a typical email that caused a crash, munged for privacy:

Received: from pu.ogauud.com (ns.ogauud.com [x.x.x.x])
by ogud.com (8.12.11/8.12.11) with ESMTP id j2AGv5qW008089;
Thu, 10 Mar 2005 11:57:05 -0500 (EST)
(envelope-from [email protected])

resulting in:

"Invalid date and time Thu, 10 Mar 2005 11:57:05 -0500 (EST)
(envelope-from [email protected])."

Another:

Received: by mailagent1.ientrymail.com (PowerMTA(TM) v2.0r1) id
h5hp7m03us84; Mon, 7 Mar 2005 10:25:47 -0500 (envelope-from
<[email protected]>)

Resulting in:

"Invalid date and time Mon, 7 Mar 2005 10:25:47 -0500 (envelope-from
<[email protected]>)."

Examining the emails themselves showed clearly that the script was
looking at the last instance of the Received header (correctly
obviously, according to Barry's 1.0 script), which is generally the
first MTA the email hit on it's way out - so more likely the sent
time, and not the received time in my system. And of course, the odd
data appended to the headers were the result of non-standard
configuration of the sending MTA. While my inbound SMTP imap server may
also be misconfigured, at least it will be consistent ;-). And
naturally it will have the correct received time. Sort of (more later).


So I solved both problems by modifying:

repeat with aHeader in theHeaders
if aHeader starts with "Received:" then copy contents of
aHeader to receivedHeader
end repeat

with

repeat with aHeader in theHeaders
if aHeader starts with "Received:" then copy contents of
aHeader to receivedHeader
if contents of receivedHeader is not "" then exit repeat
end repeat

That results in the first Received header time being picked up. OK, all
consistent with Barry.

The next problem (which highlighted a more significant issue) is that
the script fails when it hits a timestamp that includes that odd
appendix (envelope-from [email protected]). I solved that by modifying:

set AppleScript's text item delimiters to {";"}
set theDate to (last text item of receivedHeader)
set time received of theMess to date theDate

to

set AppleScript's text item delimiters to {";", "("}
set theDate to (last text item of receivedHeader)
set time received of theMess to date theDate

However, it became evident that for some reason the script is not able
to deal with timezones in the time stamp. So:

Received: from mail pickup service by smtp1.bellevue.com with Microsoft
SMTPSVC;
Thu, 7 Apr 2005 12:18:27 -0000 (UTC)

results in the time being corrected to 12:18:27 rather than 05:18:27
which is correct for my local timezone. I am unable to find any
references in the Apple Scripting man pages to indicate a mechanism to
handle timestamps that include an offset. My imap server is set to UTC
so all timestamps show -0000 (UTC).

In any case, the script solved almost all the problems, and at least
brought the time stamps within range (+7 hours) ;-)). Thanks!
 
Top