J
Jeff Zienowicz
(HTML on for ease of reading source code)
I¹m working on a solution to an annoying and I suspect somewhat universal
problem. If you check your Exchange mail with other clients and/or
computers besides Entourage (your delegate, OWA, etc.), you¹ve probably
noticed that a message sent from OWA or by your assistant will download into
your copy of Entourage, but it won¹t be linked to the original message in
your Inbox, and the original message won¹t display the Replied status icon.
Particularly in the executive-assistant situation, this can be problematic,
as the assistant may have replied to a message, but the executive wouldn¹t
know that by looking at the incoming message¹s status flags.
Even if you don¹t have an assistant, you¹ve probably run across this when
you reply to a message via webmail ‹ the link between the reply and the
original message won¹t be reflected in Entourage. I was asked by a client
to try to ³fix² this; here¹s my first attempt. This may also be useful for
IMAP users.
The script looks through your Sent folder and reads the In-Reply-To header
from each sent message. It then attempts to locate the matching message ID
in your Inbox, based on Message ID. If it finds a match, it sets the
Replied To flag in the Inbox message and establishes a link between the the
original message and the reply. I intend to install this script for both
the executive and the assistant and run it on a schedule on both machines.
Note: In this particular case, the assistant is not a delegate of her boss;
she has the account added as a second Exchange account, as the boss wants a
single Sent folder and doesn¹t want the ³Sent By² text to appear as it does
in Entourage and Outlook when the Sender header gets added to a message sent
by a delegate.
Note these important considerations: (1) Although I¹m a programmer, I¹m not
an AppleScripter; it generally gives me a headache. And (2), This script
hasn¹t undergone much testing; I¹m posting it as-is in case it¹s of any use
to anyone and to hopefully further this conversation and perhaps improve its
functionality.
Jeff
tell application "Microsoft Entourage"
-- Exchange account: 1 in Christi's case; 2 in Deidre's
set CGExchangeAccount to 1
set allSent to every message in folder "Sent Items" of Exchange account
CGExchangeAccount
-- Loop through the Sent messages
repeat with theMessage in allSent
-- Find the In-Reply-To header in this message
set allHeaders to headers of theMessage
repeat with i from 1 to count paragraphs in allHeaders
-- If there's an In-Reply-To header in the current message, try
to locate the message to which this one is a reply
set myHeader to paragraph i of allHeaders
if myHeader contains "In-Reply-To:" then
set inReplyToID to text ((offset of "In-Reply-To: " in
myHeader) + 13) thru (length of myHeader) of myHeader
-- sometimes the Message ID starts with "<"; sometimes not
if first character of inReplyToID is not "<" then
set inReplyToID to "<" & inReplyToID
end if
-- Find all Inbox messages matching the message ID
set allOriginal to (every message in folder "Inbox" of
Exchange account CGExchangeAccount whose headers contains "Message-ID: " &
inReplyToID)
repeat with myOriginal in allOriginal
-- set Replied To status
if replied to of myOriginal is false then
set replied to of myOriginal to true
end if
-- link the items
link myOriginal to theMessage
end repeat
end if
end repeat
end repeat
end tell
I¹m working on a solution to an annoying and I suspect somewhat universal
problem. If you check your Exchange mail with other clients and/or
computers besides Entourage (your delegate, OWA, etc.), you¹ve probably
noticed that a message sent from OWA or by your assistant will download into
your copy of Entourage, but it won¹t be linked to the original message in
your Inbox, and the original message won¹t display the Replied status icon.
Particularly in the executive-assistant situation, this can be problematic,
as the assistant may have replied to a message, but the executive wouldn¹t
know that by looking at the incoming message¹s status flags.
Even if you don¹t have an assistant, you¹ve probably run across this when
you reply to a message via webmail ‹ the link between the reply and the
original message won¹t be reflected in Entourage. I was asked by a client
to try to ³fix² this; here¹s my first attempt. This may also be useful for
IMAP users.
The script looks through your Sent folder and reads the In-Reply-To header
from each sent message. It then attempts to locate the matching message ID
in your Inbox, based on Message ID. If it finds a match, it sets the
Replied To flag in the Inbox message and establishes a link between the the
original message and the reply. I intend to install this script for both
the executive and the assistant and run it on a schedule on both machines.
Note: In this particular case, the assistant is not a delegate of her boss;
she has the account added as a second Exchange account, as the boss wants a
single Sent folder and doesn¹t want the ³Sent By² text to appear as it does
in Entourage and Outlook when the Sender header gets added to a message sent
by a delegate.
Note these important considerations: (1) Although I¹m a programmer, I¹m not
an AppleScripter; it generally gives me a headache. And (2), This script
hasn¹t undergone much testing; I¹m posting it as-is in case it¹s of any use
to anyone and to hopefully further this conversation and perhaps improve its
functionality.
Jeff
tell application "Microsoft Entourage"
-- Exchange account: 1 in Christi's case; 2 in Deidre's
set CGExchangeAccount to 1
set allSent to every message in folder "Sent Items" of Exchange account
CGExchangeAccount
-- Loop through the Sent messages
repeat with theMessage in allSent
-- Find the In-Reply-To header in this message
set allHeaders to headers of theMessage
repeat with i from 1 to count paragraphs in allHeaders
-- If there's an In-Reply-To header in the current message, try
to locate the message to which this one is a reply
set myHeader to paragraph i of allHeaders
if myHeader contains "In-Reply-To:" then
set inReplyToID to text ((offset of "In-Reply-To: " in
myHeader) + 13) thru (length of myHeader) of myHeader
-- sometimes the Message ID starts with "<"; sometimes not
if first character of inReplyToID is not "<" then
set inReplyToID to "<" & inReplyToID
end if
-- Find all Inbox messages matching the message ID
set allOriginal to (every message in folder "Inbox" of
Exchange account CGExchangeAccount whose headers contains "Message-ID: " &
inReplyToID)
repeat with myOriginal in allOriginal
-- set Replied To status
if replied to of myOriginal is false then
set replied to of myOriginal to true
end if
-- link the items
link myOriginal to theMessage
end repeat
end if
end repeat
end repeat
end tell