• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Getting Mail ID
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Getting Mail ID


  • Subject: Getting Mail ID
  • From: John Haley <email@hidden>
  • Date: Mon, 04 Apr 2011 10:26:23 -0500

When I tested my Mail script directly talking to Mail and using "Selection" my script was able to get the message id number, but when I save the script with the "using terms from" so it can work as a rule, it doesn't seem to be able to get the id number and the script fails.  I used display dialogs to determine that that is where the script is dying.  I have put both version of the script below.  The reason I am trying to get the id is so that I can get the path to the attachment.  There might be an easiery more dependable way to do this.

Any pointers appreciated,

John

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"
repeat with eachMessage in theMessages
set theSubject to the subject of eachMessage as text
set RecievedDate to date received of eachMessage
set theRecipient to to recipient of eachMessage
set hope to the message id of eachMessage
It fails here set AttachPathNameMessageID to the id of eachMessage (Well I say it fails, if I select the email and click apply rules, it will work)

set attachmentsList to mail attachments of eachMessage
set theRecipient to properties of item 1 of theRecipient
set theRecipient to address of theRecipient
set AttachPathName to properties of item 1 of attachmentsList
set AttachPathNameID to the id of AttachPathName
if theRecipient = "email@hidden" then
set AttachPathAccountName to "ais"
else
set AttachPathAccountName to "ds"
end if
set AttachPathBox to "INBOX"
tell application "System Events" to set AttachPath to the path to the library folder from user domain as text
set AttachPath to AttachPath & "Mail:POP-" & AttachPathAccountName & "@email@hidden:" & AttachPathBox & ".mbox:Attachments:" & AttachPathNameMessageID & ":" & AttachPathNameID & ":"
set theAttachmentName to the name of AttachPathName
delay 3
tell application "Finder"
set FileCreatorPath to the path to the documents folder as text
set FileCreator to FileCreatorPath & "Fax Status Creator.fp7" as text
with timeout of 36000 seconds
open alias FileCreator
end timeout
end tell
delay 3
tell application "FileMaker Pro"
activate
set RecievedDate to RecievedDate as text
set theSubject to theSubject as text
tell table "Fax Status Creator" of database "Fax Status Creator"
activate
set cell "Contract Relationship Number" to theSubject
set cell "Fax Status Time" to RecievedDate
set cell "Contract Type" to theRecipient
set cell "File Name" to theAttachmentName
set cell "Contract Path" to AttachPath
do script "Enter Contract Info"
end tell
end tell
end repeat
end tell
end perform mail action with messages
end using terms from

This script works on the same email

tell application "Mail"
activate
set theMessages to the selection
repeat with eachMessage in theMessages
set theSubject to the subject of eachMessage as text
set RecievedDate to date received of eachMessage
set theRecipient to to recipient of eachMessage
set hope to the message id of eachMessage
set AttachPathNameMessageID to the id of eachMessage
set attachmentsList to mail attachments of eachMessage
set theRecipient to properties of item 1 of theRecipient
set theRecipient to address of theRecipient
set AttachPathName to properties of item 1 of attachmentsList
set AttachPathNameID to the id of AttachPathName
if theRecipient = "email@hidden" then
set AttachPathAccountName to "ais"
else
set AttachPathAccountName to "ds"
end if
set AttachPathBox to "INBOX"
tell application "System Events" to set AttachPath to the path to the library folder from user domain as text
set AttachPath to AttachPath & "Mail:POP-" & AttachPathAccountName & "@email@hidden:" & AttachPathBox & ".mbox:Attachments:" & AttachPathNameMessageID & ":" & AttachPathNameID & ":"
set theAttachmentName to the name of AttachPathName
delay 3
tell application "Finder"
set FileCreatorPath to the path to the documents folder as text
set FileCreator to FileCreatorPath & "Fax Status Creator.fp7" as text
with timeout of 36000 seconds
open alias FileCreator
end timeout
end tell
delay 3
tell application "FileMaker Pro"
activate
set RecievedDate to RecievedDate as text
set theSubject to theSubject as text
tell table "Fax Status Creator" of database "Fax Status Creator"
activate
set cell "Contract Relationship Number" to theSubject
set cell "Fax Status Time" to RecievedDate
set cell "Contract Type" to theRecipient
set cell "File Name" to theAttachmentName
set cell "Contract Path" to AttachPath
do script "Enter Contract Info"
end tell
end tell
end repeat
end tell
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Mail Rules and getting ID number
  • Next by Date: Re: Getting rid of web page warning - Opening .html pages stored on drive -
  • Previous by thread: Re: Getting rid of web page warning - Opening .html pages stored on drive -
  • Next by thread: Renaming files
  • Index(es):
    • Date
    • Thread