I am having trouble with a script I am working on to transfer email messages and attachments to text files. There are instances (not all) where I cannot return the content of the message. To try and establish what the problem is I redirected one of the offending messages with the attachment changed and the message itself replace with “Original Text Replaced”. I then wrote a simple scrip (below) to return the subject, senders name and the content. Please accept the message did have content.
tell application “Mail”
set the_message to item 1 of (get selection as list)
display dialog subject of the_message as string
display dialog (extract name from sender of the_message as string)
display dialog content of the_message as string
end tell
I logged the scrip as it ran and the results are below as can be seen the subject and senders name were correctly returned but not the content.
tell application “Mail”
get selection
{message id 23888 of mailbox “Test/Test10”}
get subject of message id 23888 of mailbox “Test/Test10”
“5 New Text & Doc”
display dialog “5 New Text & Doc”
{button returned:“OK”}
get sender of message id 23888 of mailbox “Test/Test10”
“"MCCARTHY, Dorothy" dorothy.mccarthy@oup.com”
extract name from “"MCCARTHY, Dorothy" dorothy.mccarthy@oup.com”
“MCCARTHY, Dorothy”
display dialog “MCCARTHY, Dorothy”
{button returned:“OK”}
get content of message id 23888 of mailbox “Test/Test10”
“???”
display dialog “???”
{button returned:“OK”}
end tell
I then saved the message by selecting Save As from mail as a text file that I copied as is shown below and it can be seen it does have text which should have been captured as the content.
Resent-From: peter mitchell mitch@surfbvi.com
From: “MCCARTHY, Dorothy” dorothy.mccarthy@oup.com
Date: February 1, 2006 5:58:07 AM GMT-04:00
Resent-To: Mitchell UK Peter & Gloria mitch@vail.net
To: mitch@surfvi.com, mitchbvi@btinternet.com, mitch@vail.net
Subject: 5 New Text & Doc
Original Text Replaced
I feel it must be something embedded in the email message but I cannot work out what or how to find out. I have backspaced to delete the text and attachment from the original email message then added new text and attachment. It still refuses to return the content of the email. If I use mail to remove the attachment and run the scrip above it returns the notification that the attachment has been removed but still does not show the original content as can be seen from this log.
tell application “Mail”
get selection
{message id 23901 of mailbox “Sent Messages” of account “Surfbvi”}
get subject of message id 23901 of mailbox “Sent Messages” of account “Surfbvi”
“5 New Text & Doc”
display dialog “5 New Text & Doc”
{button returned:“OK”}
get sender of message id 23901 of mailbox “Sent Messages” of account “Surfbvi”
“"MCCARTHY, Dorothy" dorothy.mccarthy@oup.com”
extract name from “"MCCARTHY, Dorothy" dorothy.mccarthy@oup.com”
“MCCARTHY, Dorothy”
display dialog “MCCARTHY, Dorothy”
{button returned:“OK”}
get content of message id 23901 of mailbox “Sent Messages” of account “Surfbvi”
"?
[The attachment Test for email attachments.doc has been manually removed]
?"
display dialog "?
[The attachment Test for email attachments.doc has been manually removed]
?"
{button returned:“OK”}
end tell
I would greatly appreciate any help or suggestions.
Thanks
peter