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
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