Using Applescript to track Mail "Mark as Unread"

Hi,
I'm new to actionscript, I've never written anything using it. I'm a web developer, so I know JS, PHP and languages like that, but Applescript seems quite different to me.
Anyways, I would like to know if it is possible to have a script in the background with an event handler that will trigger additional actions when a message is marked as unread?
Pretty much, I want some code (that I will work out later) to be executed when a user marks a message as unread in Mail. ("Message"->"Mark"->"As Unread" OR ⇧⌘U)
Thanks

I'm new to actionscript
You mean AppleScript, right?
I would like to know if it is possible to have a script in the background with an event handler that will trigger additional actions when a message is marked as unread?
Not directly. The ideal way of doing this would be for Mail.app to have some kind of option to attach AppleScripts to events within the application. It's entirely possible to do within the OS, but few applications take advantage of it - that includes Mail.app, so there's no way to have Mail.app call your script directly.
The closest you could get would be a background script that silently polled Mail.app for the status of all messages and somehow detect when a message went from Read to Unread. This could be unwieldy, especially if there are many, many messages in the mailbox - you pretty much have to keep track of every read message and scan for any unread messages that are in the previous read messages list. This option doesn't work if you want to perform some real-time action such as interact with the user since there would always be some delay between the user action (marking the message unread) and the script noticing it.

Similar Messages

  • Sent Mail Marked As Unread

    In Lion Mail, sent mail is being marked as unread. Why is that? Can I change that behaviour or is this a bug maybe?

    A couple further details...
    Using a .me account
    I sent 3 emails, one after the other, to my work address, 2 of the 3 show up as Unread in the Sent, though all 3 were received by my work address
    Using the same .me outgoing server for all emails
    There are no Rules in effect that would cause this
    This seems to happen at random to only maybe 1 or 5 sent emails
    They are going to both .me and other domains.

  • E-mails marked as unread when viewed on B'berry

    I receive my Outlook e-mails onto my Blackberry but when I've read them on my device it marks them as read in Outlook on my pc.  How can I leave the Outlook e-mails showing as unread even when they have been read on my Blackberry?
    Thanks

    Hi and Welcome to the Forums!
    If you are on BES, then you will need to go see your BES admins to determine if what you desire is allowed in that system...they are in control.
    For BIS-based email, you can defeat wireless reconciliation by, from within any messages list, going here:
    BBKey > Options > Email Reconciliation > Make sure that the Message Services is set to the account you want to change > Change Wireless Reconcile to "Off"
    Note that this will not only remove reconciliation of read/unread...it will remove all OTA reconciliation features. You will then have to use Outlook to truly control your actual mailbox...nothing you do on your BB will affect your actual mailbox.
    Cheers!
    Occam's Razor nearly always applies when troubleshooting technology issues!
    If anyone has been helpful to you, please show your appreciation by clicking the button inside of their post. Please click here and read, along with the threads to which it links, for helpful information to guide you as you proceed. I always recommend that you treat your BlackBerry like any other computing device, including using a regular backup schedule...click here for an article with instructions.
    Join our BBM Channels
    BSCF General Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • Using AppleScript to save Mail messages?

    I'm a bit of an Applescript newbie, but I'm trying to attach an AppleScript to a rule in Mail to automatically save the raw text source of certain mail messages to a folder, where I can further process them.
    Here's what I have so far. It compiles, is saved in my Mail scripts folder, and It is attached to the rule in Mail, but I get no evidence that it runs (no output file(s), no dialogs, no messages in the console or system logs).
    using terms from application "Mail"
    on perform mail action with messages theMessages
    tell application "Mail"
    repeat with eachMessage in theMessages
    save the source of eachMessage in "hd/Users/me/Desktop/slash.txt" as text
    save the source of eachMessage in "hd:Users:me:Desktop:colon.txt" as text
    end repeat
    end tell
    end perform mail action with messages
    end using terms from
    Any suggestions?
    G4 "Gigabit" Dual-500   Mac OS X (10.4.8)   1.5GB RAM, 1TB internal, SCSI, 802.11g, USB2.0

    Hi 0g,
    Automator is pretty simple compared to AppleScript. I use Automator, but I certainly could not help you with AppleScript! So I'm not sure you will find your answer here... You might, but why don't you increase your chances by posting in the AppleScript Forum here: http://discussions.apple.com/forum.jspa?forumID=724
    (You probably didn't see that one as it is hidden in the Mac OS X Technologies Category!)
    Good luck!
    Guylaine
    Mac mini Intel Core Duo 1.66 GHz 512MB DDR2 SDRAM Mac OS X (10.4.8) G4 Digital Audio Mac OS 9.2.2, iPod nano 1GB, iPod nano 4GB

  • TS4083 Mail says I have unread emails, but no emails are marked as unread?

    When checking my mail using icloud.com, 2 of my VIP folders are saying I have unread emails, when i go into the folders I have no emails marked as unread. I have checked on my macbook mail and I also have no emails unread on there either. How do i know if I have viewd my emails or not?

    it  say,s that cris  as got 23 Messages in  the vip inbox that  are  unread but  can  you see they  are read  can you help

  • Why is Sent Mail marked Unread?

    On my computer, when I send mail it goes into my "Sent Mail" mailbox and is marked as "read." That's the way it seems to me things should be.
    However, on my husband's computer (both of us are using 10.4.4), the mail goes into the Sent Mail box and is marked "unread", which is problematic. Is there a fix for this?
    Thanks for any help you can offer!

    It sounds like you need to setup your account in your browser correctly and then delete Gmail in Mail and add it back with the new settings. See directions here. Most users have multiple Sent folders in Settings > Labels. Until you clean up online, it's difficult to get Gmail working in Mavericks Mail.
    Use Gmail with Mavericks Mail
    http://www.needhelp4mac.com/2013/12/use-gmail-with-mavericks-mail/
    (Fair disclosure: Needhelp4Mac is my site. I may receive some form of compensation, financial or otherwise, from my recommendation or link.)

  • Mail Rules missing "mark as unread" and "mark as unflagged"

    I'm adding some new rules in Mac Mail and just noticed that there is no option to "mark as unread" in my list. My friend has it coming up, but it isn't there for me.
    When I click to add a new rule, the drop-down for Perform actions lists "delete", "mark as read" and "mark as flagged". I'm missing "mark as unread" and "mark as unflagged".
    Why would I be missing those options?
    Thanks,
    Morton++

    Mail rules doesn't offer these options which is why you don't have them. Your friend must be mistaken. and anyway since the rules are only applied to new messages there is no point in having the option to mark them as unread - they are unread already. You can add a rule to unflag messages using apple script but if I'm not mistaken all new messages are unflagged by default too so there is no point for this one either.

  • Some read mail items remain marked as unread

    Some read mail items remain marked as unread (even after I've read them).
    I have to manually mark them as read.
    This doesn't happen to all mail items, just some.
    How can I fix this?

    A few discoveries I made this morning.
    One is that disabling GPGMail seems to solve the problem, or at least significantly reduce its occurrence.
    Another is that with GPGMail enabled, it seems to depend on how quickly one opens an email. I can't say for sure that this is a hard and fast rule, but messages staying unread seems to be more of a problem if you've just entered the folder or just been viewing another message and suddenly change to an unread one. It's as though GPGMail causes Mail to need some time to think things through.
    A third is that if you have multiple mail accounts, a workaround to reset the unread count exists. If a mail folder in Account One is having problems, you can switch to a folder in Account Two, possibly wait an interval of time (not sure what that interval would be), then switch back to your original Account One folder. That seems to force a refresh of the unread count, without needing a folder rebuild (with consequent loss of expanded threads, etc).
    However, for the time being, I've just disabled GPGMail. I can re-enable it as needed, by the looks of it, and it's not as though I've really needed to use it yet.
    I could wish, though, that Apple offered proper GPG support, or at least that they made enough of their API available that third parties could do a proper job instead of an ugly and somewhat broken hack. (I've also seen complaints that Apple like to change their API without telling anyone, just to keep third-party developers on their toes =P.) I suppose another problem is lack of available time. Which I also suffer from, so I don't think a "real solution" is forthcoming from this quarter, at least.

  • Unread Mail marked as "Read"

    We have multiple mail accounts set up on multiple devices  (using 10.9.2).  Some of us receive the same email from a sender.  When one of us reads the email, it is marking the email as "read" in all the accounts when only read in one.  Fix?  This just started with the most recent update.  Any ideas on why this is happening and a fix for it?

    I have had the same issue with my Microsoft exchange email after upgrading to Lion.  It's a bit annoying.  My iPad, Android Phone, and viewing it using a browser all show 0 unread, but Mail shows 3 unread.  I have tried deleting the account, rebuilding, and pawing through settings looking for something I missed. Nothing.  I actually had the same problem with my MobileMe email with Snow Leopard but I eventually permanently removed the account as other problems arose and just used it in my browser.
    Sorry I couldn't help but I hope it's resolved.
    John

  • TS3899 I have a yahoo email account setup on my iPad & iPhone.  The new mail is never marked as unread when downloaded to my iPad or iPhone. Is there anyway to fix this?

    I have a yahoo email account setup on my iPad & iPhone.  The new mail is never marked as unread when downloaded to my iPad or iPhone. Is there anyway to fix this?

    Hey there Fabian, 
    If I understand correctly you are going to Settings > Mail, Contacts, and Calendars > Add Account but that last option is not usable because it is gray. In testing this for you, I was able to reproduce this by enabling Restrictions and denying Account Changes. You can configure that with this article:
    About Restrictions (parental controls) on iPhone, iPad, and iPod touch
    Thank you for using Apple Support Communities.
    Regards,
    Sterling

  • How to set stationery in Mail, using AppleScript

    Is there a way to automatically use specific stationery with Mail, from an AppleScript script?
    To the script below I would like to add an instruction which asigns stationery to the mail message, and so far I have not yet found a working way of doing it.
    on run {theSubject, theBody, theAttachment}
              tell application "Mail"
                        set newMessage to make new outgoing message with properties {visible:true, subject:theSubject, content:theBody & return & return}
                        tell content of newMessage
      make new attachment with properties {file name:theAttachment} at after the last paragraph
                        end tell
      activate
              end tell
    end run
    I found an Automator example which requires the installation of an action, but once installed, it does not work. (It must have worked in OSX 10.6, but it does not on Mountain Lion) Here: Automator: Examples
    Any ideas, anyone?
    Thanks, Oliver

    try this:
    tell application "Numbers"
              tell table 1 of sheet 1 of document 1
                        repeat with i from 1 to row count
                                  if value of cell 14 of row i is equal to renew_month then
                                            set address_to to value of cells of row i
                                  end if
                        end repeat
              end tell
    end tell

  • All mail is marked as unread following iOS 7 install.  How do I fix that?

    All mail is marked as unread following iOS 7 install.  How do I fix that?

    Ignore my last question.  This was entirely user inflicted.
    The count that shows on the mail icon on the iPad shows the number of email in the "New" folder on my AOL account.  Some of these are emails that I read and then marked as unread.  In the previous versions, these "read and then marked as unread' emails did not show in the count on the iPad icon...but now they do.  Not a big deal...it's just different.
    Thanks for your help.

  • Mail messages are constantly marked as "Unread"

    On certain mail messages, I cannot get the message to remain as "Marked Read"  - the message continues to come to my Mac as "New".  I have tried deleting message, manually marking it as Read.  Nothing seems to work.  Please share any advice.

    This stopped happening as mysteriously as it started for me. The only change made on my end is that I added some seemingly unrelated filter Rules - around the same time (i can't be entirely certain if it stopped before or after the Rule changes) the proble with sent messages being marked as unread stopped. I doubt that the Rules actually had a direct effect, though perhaps it altered the structure of memory enough to stop the bug from occurring (something which I've seen many times in my 40 years of programming).

  • Using AppleScript to auto-archive mail in Outlook 2011

    I want to use AppleScript to set up a schedule to auto-archive mail greater than X days old. What I've found so far is below, and the error I'm receiving is "error "Microsoft Outlook got an error: Can’t get pop account \"TargetProcess\"." number -1728 from pop account "TargetProcess"".
    # the time we want to archive from
    set theArchiveCutoffTime to ((current date) - (32 * days))
    property theCount : 0
    tell application "System Events"
      set targetProcess to count (every application process whose name is "Mail")
    end tell
    tell application "Microsoft Outlook"
      set thisAccount to pop account "TargetProcess"
      set thisFolders to mail folder of thisAccount
    # find the "Inbox" of topFolder and "Mail ARCHIVE" of on my computer
      repeat with thisFolder in thisFolders
      if name of thisFolder is "Inbox" then
      set theInbox to thisFolder
      else if name of thisFolder is "Mail ARCHIVE" then
      set theARCHIVE to thisFolder
      end if
      end repeat
    # find the archive "Inbox"
      repeat with thisFolder in mail folder of theARCHIVE
      if name of thisFolder is "Inbox" then
      set theArchiveInbox to thisFolder
      end if
      end repeat
      set theArchiveTarget to theArchiveInbox
    # archive the Inbox
      repeat with theMessage in message in theInbox
      if time received of theMessage < theArchiveCutoffTime then
      move theMessage to theArchiveTarget
      set theCount to theCount + 1
      else
      # we get messages from oldest to newest
      exit repeat
      end if
      end repeat
    # archive sub-folders
      repeat with thisSubfolder in mail folder of theInbox
      # find the archive subfolder corresponding to this
      repeat with thisARCHIVEubfolder in mail folder of theArchiveInbox
      if name of thisARCHIVEubfolder is name of thisSubfolder then
      set theArchiveTarget to thisARCHIVEubfolder
      end if
      end repeat
      # archive messages
      repeat with theMessage in message in thisSubfolder
      if time received of theMessage < theArchiveCutoffTime then
      move theMessage to theArchiveTarget
      set theCount to theCount + 1
      else
      # we get messages from oldest to newest
      exit repeat
      end if
      end repeat
      end repeat
    end tell
    I'm working in AppleScript Editor v2.6.1 (152.1), Microsoft Outlook 2011 v14.3.5, OSX 10.9.4 Mavericks.

    Ok, red_menace above me had a shorter and more elegant solution to the question, I'm adding this just for another example.
    To solve your problem I'd make a mail rule that looked for any messages with "Filename:" in them (along with whatever criteria you wanted, like sender, domain, etc). The mail rule would execute the Applescript. My assumption is that the "Filename:foobar" text could be anywhere in the email, not necessarily the first thing in a paragraph, so I had to parse it differently.
    The results end up in a datalist, (theFilename {} ) that you can parse later to collect all filenames found in whatever messages were processed.
    I realize this could be cleaner, hope it's not hard to follow, but I did it really fast. It works flawlessly for me, picking out the name of the file no matter where in the email it appears.
    using terms from application "Mail"
    on perform mail action with messages theSelectedMessages for rule theRule
    repeat with aCounter from 1 to count theSelectedMessages
    set theMessage to item aCounter of theSelectedMessages
    set theContent to content of theMessage
    set theWords to every word of theContent
    set theFilename to {}
    set tid to AppleScript's text item delimiters
    set AppleScript's text item delimiters to ":"
    repeat with thisLoop in theWords
    try
    if (text item 1 of thisLoop) is "Filename" then
    set end of theFilename to (text item 2 of thisLoop)
    -- rest of your logic goes here the display is just to show it finds the filename, take it out!
    display dialog theFilename ¬
    buttons {"OK"}
    end if
    end try
    end repeat
    set AppleScript's text item delimiters to tid
    end repeat
    end perform mail action with messages
    end using terms from
    Message was edited by: stephen.bradley Typos for the win!

  • Using AppleScript to remotely shutdown a mail server?

    Hello all AppleScript gurus,
    Here is the situation. My friend's company (it is a small company) uses a Linksys NAS 200 as a mail server. They recently purchased an APC BackUps 1000 Pro as the universal power supply (yes I am aware that it is not suitable for business purposes, but the boss is a cheapskate).
    I would like to be able to shutdown the server remotely when the UPS tells the mac laptop (running 10.7.5) that power is being supplied by the battery. However, APC's software for OS X is nonexistant, and the options in energy saver in system prefs are limited.
    Would it be possible to use AppleScript to send a message to the server to shutdown upon receiving a warning from the UPS? If so, how would this be accomplished?
    Many thanks in advance in case I forget to say thank you again after. If further information is required, I'll do my best to supply the info.
    Thanks again.
    Ian

    I'd figure out how to do the shutdown from the command line.  You then should be able to do this from an applescript.
    There is some way of initiating an apple script on a remote machine but I do not know how.
    What OS is the remote server using?
    Robert

Maybe you are looking for

  • Customer &Vendor ageing Report

    HI, While executing the vendor & Customer ageing  Report, There is no way to give profit center in "dynamic selection button, but we have activated New gl accounting and document splitting , Is there any way to give profit center. Pl. give me guide l

  • Dick Permission--"ACL" found but not expected...

    Safari/internet access is great after I do a disk permission verify & repair. After a week or so it is back to the slow mode. WHAT is "ACL"? and why does it go back after I have repaired the disk permissions? Here is a typical line of the detail ACL

  • Problem in Uploading Excel Data ! - Urgent

    Dear Experts, I am uploading excel data using FM 'TEXT_CONVERT_XLS_TO_SAP' , its directly convert data and store in internal table same as in excel sheet(row , column wise). But the problem is , one of the column having description more then 500 char

  • Multiple cursors opened when following BC4J Entity Association in a loop

    I am using BC4J in JDeveloper 9.0.4.1.1 Build 1436 against a 9.0.2 database. (Note the BC4J project was originally created in a 9.0.3 JDeveloper release) In the BC4J project, I have a "Contract" Entity that has a 1-to-1 Association with an "Estimate"

  • Blue Ray not supported in OSX

    Why is Blue Ray not supported?? Can someone from Apple please address this....and hopefully someday this will be rectified.