J
Jon Connell
I think I have a workaround for this problem:
http://support.microsoft.com/kb/926521
Basically, rewriting the sent item in AppleScript. I am almost there,
but I can't get the "make new recipient" bit of this script work.
Anyone have any ideas?
Jon
tell application "Microsoft Entourage"
set selectedMessages to current messages
if selectedMessages is {} then
display dialog "Please select a message first and then run this
script." with icon 1
return
end if
repeat with theMessage in selectedMessages
set theHeaders to headers of theMessage
set lineOne to paragraph 1 of theHeaders
set lineTwo to paragraph 2 of theHeaders
if lineOne begins with "MAIL FROM: " and lineTwo begins with "RCPT
TO: " then
set theBody to the content of theMessage
set paragraphList to every paragraph of theBody
set newHeaders to ""
set newBody to ""
set myState to "header"
set ccString to ""
set toString to ""
set theSubject to ""
set theDate to ""
repeat with i from 1 to the count of paragraphs of theBody
set thisParagraph to item i of the paragraphList
if thisParagraph = "" then
set myState to "body"
else
if (myState = "cc" or myState = "to") and thisParagraph contains
":" then
set myState to "header"
set AppleScript's text item delimiters to tid
end if
if myState = "header" then
if thisParagraph begins with "Subject: " then
set theSubject to thisParagraph
else if thisParagraph begins with "From: " then
set theSender to thisParagraph
else if thisParagraph begins with "To: " then
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "To: "
set theToString to text item 2 of thisParagraph
set myState to "to"
else if thisParagraph begins with "Cc: " then
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "Cc: "
set theCcString to text item 2 of thisParagraph
set myState to "cc"
else if thisParagraph begins with "Date: " then
set theDate to thisParagraph
end if
set newHeaders to newHeaders & thisParagraph & (ASCII character
13)
else if myState = "cc" then
set theCcString to theCcString & thisParagraph
else if myState = "to" then
set theToString to theToString & thisParagraph
else if myState = "body" then
set newBody to newBody & thisParagraph & (ASCII character 13)
end if
end if
end repeat
set recipientList to {}
if theCcString $B!b(B "" then
set AppleScript's text item delimiters to ","
set theRecipients to every text item of theCcString
repeat with thisRecipient in theRecipients
if thisRecipient contains "<" and thisRecipient contains ">" then
set AppleScript's text item delimiters to "<"
set displayName to text item 1 of thisRecipient
set recipientAddress to text item 2 of thisRecipient
set AppleScript's text item delimiters to ">"
set recipientAddress to text item 1 of recipientAddress
else
set displayName to thisRecipient
set recipientAddress to thisRecipient
end if
if displayName contains "\"" then
set AppleScript's text item delimiters to "\""
set displayName to text item 2 of displayName
end if
make new recipient at end of recipientList with properties
{recipient type:cc recipient, address:{display name:displayName,
address:recipientAddress}}
end repeat
end if
if theToString $B!b(B "" then
set AppleScript's text item delimiters to ","
set theRecipients to every text item of theToString
repeat with thisRecipient in theRecipients
if thisRecipient contains "<" and thisRecipient contains ">" then
set AppleScript's text item delimiters to "<"
set displayName to text item 1 of thisRecipient
set recipientAddress to text item 2 of thisRecipient
set AppleScript's text item delimiters to ">"
set recipientAddress to text item 1 of recipientAddress
else
set displayName to thisRecipient
set recipientAddress to thisRecipient
end if
if displayName contains "\"" then
set AppleScript's text item delimiters to "\""
set displayName to text item 2 of displayName
end if
make new recipient at end of recipientList with properties
{recipient type:to recipient, address:{display name:displayName,
address:recipientAddress}}
end repeat
end if
set recipients of theMessage to theRecipients
set sender of theMessage to theSender
set subject of theMessage to theSubject
set time sent of theMessage to date theDate
set content of theMessage to newBody
end if
end repeat
end tell
http://support.microsoft.com/kb/926521
Basically, rewriting the sent item in AppleScript. I am almost there,
but I can't get the "make new recipient" bit of this script work.
Anyone have any ideas?
Jon
tell application "Microsoft Entourage"
set selectedMessages to current messages
if selectedMessages is {} then
display dialog "Please select a message first and then run this
script." with icon 1
return
end if
repeat with theMessage in selectedMessages
set theHeaders to headers of theMessage
set lineOne to paragraph 1 of theHeaders
set lineTwo to paragraph 2 of theHeaders
if lineOne begins with "MAIL FROM: " and lineTwo begins with "RCPT
TO: " then
set theBody to the content of theMessage
set paragraphList to every paragraph of theBody
set newHeaders to ""
set newBody to ""
set myState to "header"
set ccString to ""
set toString to ""
set theSubject to ""
set theDate to ""
repeat with i from 1 to the count of paragraphs of theBody
set thisParagraph to item i of the paragraphList
if thisParagraph = "" then
set myState to "body"
else
if (myState = "cc" or myState = "to") and thisParagraph contains
":" then
set myState to "header"
set AppleScript's text item delimiters to tid
end if
if myState = "header" then
if thisParagraph begins with "Subject: " then
set theSubject to thisParagraph
else if thisParagraph begins with "From: " then
set theSender to thisParagraph
else if thisParagraph begins with "To: " then
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "To: "
set theToString to text item 2 of thisParagraph
set myState to "to"
else if thisParagraph begins with "Cc: " then
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to "Cc: "
set theCcString to text item 2 of thisParagraph
set myState to "cc"
else if thisParagraph begins with "Date: " then
set theDate to thisParagraph
end if
set newHeaders to newHeaders & thisParagraph & (ASCII character
13)
else if myState = "cc" then
set theCcString to theCcString & thisParagraph
else if myState = "to" then
set theToString to theToString & thisParagraph
else if myState = "body" then
set newBody to newBody & thisParagraph & (ASCII character 13)
end if
end if
end repeat
set recipientList to {}
if theCcString $B!b(B "" then
set AppleScript's text item delimiters to ","
set theRecipients to every text item of theCcString
repeat with thisRecipient in theRecipients
if thisRecipient contains "<" and thisRecipient contains ">" then
set AppleScript's text item delimiters to "<"
set displayName to text item 1 of thisRecipient
set recipientAddress to text item 2 of thisRecipient
set AppleScript's text item delimiters to ">"
set recipientAddress to text item 1 of recipientAddress
else
set displayName to thisRecipient
set recipientAddress to thisRecipient
end if
if displayName contains "\"" then
set AppleScript's text item delimiters to "\""
set displayName to text item 2 of displayName
end if
make new recipient at end of recipientList with properties
{recipient type:cc recipient, address:{display name:displayName,
address:recipientAddress}}
end repeat
end if
if theToString $B!b(B "" then
set AppleScript's text item delimiters to ","
set theRecipients to every text item of theToString
repeat with thisRecipient in theRecipients
if thisRecipient contains "<" and thisRecipient contains ">" then
set AppleScript's text item delimiters to "<"
set displayName to text item 1 of thisRecipient
set recipientAddress to text item 2 of thisRecipient
set AppleScript's text item delimiters to ">"
set recipientAddress to text item 1 of recipientAddress
else
set displayName to thisRecipient
set recipientAddress to thisRecipient
end if
if displayName contains "\"" then
set AppleScript's text item delimiters to "\""
set displayName to text item 2 of displayName
end if
make new recipient at end of recipientList with properties
{recipient type:to recipient, address:{display name:displayName,
address:recipientAddress}}
end repeat
end if
set recipients of theMessage to theRecipients
set sender of theMessage to theSender
set subject of theMessage to theSubject
set time sent of theMessage to date theDate
set content of theMessage to newBody
end if
end repeat
end tell