I want to find a simple way to see if a messages was sent or received . the following handler works for enable accounts but now for all the users email address on that account.
on StatusEmail(Sender_, CheckSender) --Determine if Mail is Received or Sent by the User tell application "Mail" display dialog Sender_ set emailAddressList to (email addresses of every account whose enabled is true) --Returns all the users email addresses display dialog emailAddressList & " " & CheckSender as string if (emailAddressList as string) contains (CheckSender) then set Status_ to "Outward" set Sender_ to "" --Blank as Sender was the user display dialog "Status " & Status_ else --Must be inward email set Status_ to "Inward" try --Extract Name of sender or set it to part before the @ symbol set Sender_ to extract name from Sender_ on error --Means only an email address so set sender to part if front of the @ symbol set brkpos to offset of "@" in Sender_ set Sender_ to characters 1 through (brkpos - 1) of Sender_ end try display dialog "Status " & Status_ end if end tell end StatusEmail
For instance my address is firstname.lastname@example.org which is returned by the script but if I sent a message from email@example.com that is not identified as a sent message. I realise I could create a list of all my email addresses and check against all of them but I was trying to make it a little more user friendly.