AppleScript for marking messages read in specific mailboxes

Hello
I'd like to ask whether there is someone out there with a good AppleScript knowledge who could help me out with this problem.
As far as I know, Mail currently does not support subscribing / unsubscribing to IMAP folders, which is why my "spam" folders are also being used to show the total number of unread messages in my mailboxes.
My idea is to use a script to mark all messages from specific mailboxes (namely "INBOX/spam" on all accounts) as read, as soon as they are received. All the spam mails are filtered by my provider and put into the "spam" mailbox with a subject containing "*SPAM*" automatically.
Anybody an idea?
Regards
Peter.
Message was edited by: peschehimself

Try this:
tell application "Mail"
repeat with each_account in accounts
tell each_account
repeat with each_mailbox in mailboxes
if name of each_mailbox contains "spam" then
set (read status of messages of each_mailbox whose subject contains "*SPAM*") to true
end if
end repeat
end tell
end repeat
end tell
But if you have a lot of '*SPAM*' messages in those folders it will still have to evaluate all of them and may be slow as a result.
H

Similar Messages

  • Song is paid for yet message reads "your computer is not authorized to play this song"

    song is paid for yet message reads "your computer is not authorized to play this song"

    Hi bboywerx,
    For that message you would want to try authorizing your computer again:
    iTunes Store: About authorization and deauthorization
    http://support.apple.com/kb/HT1420
    To authorize a computer using your Apple ID
    Open iTunes
    From the Store menu, choose Authorize This Computer. (In earlier versions of iTunes, access this option from the Advanced menu).
    When prompted, enter your Apple ID and password, then click Authorize.
    Cheers!
    - Ari

  • Mail with Exchange 2007 - Rules for "Mark as Read" and "Move to Folder"

    I have seen this posted before, but never any resolution. This is very frustrating to me.
    I have an Exchange account set up in the the latest version of Mail.app (4.4.1082) for OS X 10.6.6. I have rules set up for this account that tell Mail.app to mark the message as read after moving the message to a specific folder if it meets the provided criteria. The rule does move the message to the proper folder, but it does not mark the message as read. This only seems to affect Exchange accounts.
    Has anybody experiencing this found a resolution? I have tried separating the rules or putting them in a different order (and mail just reorders them the way it wants which is frustrating to me as well). Seems no matter how I do it the mail either gets marked and not moved or moved and not marked.

    Anyone have any thoughts?

  • AppleScript for marking up footnotes in MS Word

    Hello. I'm trying to write a script for marking up footnotes in MS Word (2008) that takes this:
    and does this to it:
    Any suggestions, pointers welcome, even if they don't amount to a full solution.
    Here is what I have. At the moment it handles one replacement at a time (so I have to run it several times to go through a document full of footnotes), and not very well. It replaces the superscript footnote reference number with "\footnote{}<footnote text>" -- so puts the text after rather than within the two braces.
    tell application "Microsoft Word"
        set myFind to find object of selection
        clear formatting of myFind
        set style of myFind to "Footnote Reference"
        set content of myFind to ""
        execute find myFind -- replace replace all
        if found of myFind is true then
            copy object text object of footnote 1 of selection
            set superscript of font object of selection to false
            set style of selection to "normal"
            type text selection text "\\footnote{"
            set myRange to collapse range text object of selection direction collapse start
            paste special myRange data type paste text
            type text selection text "}"
        end if
    end tell
    [footnote 1 of the selection should always be the footnote text corresponding to the footnote reference number selected by a find -- that bit seems to work]

    Hi,
    mephisto8 wrote:
    I would be happy if I could get the whole script to either i) find italicized text in footnotes and replace it with \emph{italicized text}.
    This works
    tell application "Microsoft Word"
         set {tStart, tEnd} to {start of content, end of content} of text object of selection
         set oldSel to create range (active document) start tStart end tEnd
         select first character of text object of footnote 1 of active document
         move range (text object of selection) by a character item count -1
         set myFind to find object of selection
         clear formatting of myFind
         set italic of font object of myFind to true
         set content of myFind to ""
         clear formatting replacement of myFind
         set content of replacement of myFind to "\\emph{^&}"
         set italic of font object of replacement of myFind to false
         execute find myFind replace replace all
         select oldSel
         clear formatting of myFind
         set style of myFind to "Footnote Reference"
         repeat while execute find myFind
              tell selection
                   set x to end of content of text object of footnote 1
                   copy object text object of footnote 1
                   set superscript of font object to false
                   set style to "normal"
                   type text text "\\footnote{"
                   paste special (collapse range text object direction collapse start) data type paste text
                   delete first character -- remove the space before the pasted text
                   move range (text object) by a character item count (x - 2)
                   type text text "}"
              end tell
         end repeat
    end tell

  • Why when using firefox to read e-mails in outlook can't I mark messages as unread?

    there's no option for "mark message as unread" when running outlook in firefox.
    Why?

    Okay so I randomly typed "gmail" into the "Domain" field in the Exchange setup after reading your response and it seemed to work. That gave me the option to "flag" or "unflag" a message by clicking the little flag icon in the mail app. That's a start. But then I realized that when I flag a message, it doesn't show as flagged in Apple Mail or in Gmail's web client. However when I flag messages on my Mac they show as flagged in Gmail's web client but not my iPhone. My Mac and the web client seem to be syncing just fine but not my iPhone. Weird. I'll read that thread now...

  • Mail will not mark messages as read after being opened

    Mail will not mark messages as read after being opened... the blue dot will NOT go away, no matter how many times I open the e-mail.
    It's a simple pop account. I AM able to mark messages read with the message menu item (mark as read.) I also have nothing synced with it, no iPhone, no IMAP accounts, no .mac account, nothing.
    But this is a real pain to have to do manually, when it used to happen automatically upon clicking the e-mail, it opening in a window to read, and then closing it.
    All was working fine up until the 10.5.7 update. I hoped the 10.5.8 update would fix the problem, but no change. Everything else is working perfectly (I do the permissions repair/disk verify procedure before and after each update.)
    Can't seem to find anyone else with this problem in here either, through search or just going through hundreds of messages.

    Okay, then lets try this:
    1. Select all your messages in the Inbox; then use the contextual menu or the Message > Mark menu to mark them all as Read.
    2. Quit Mail.
    3. Go to Home/Library/Mail and delete the Envelope Index file.
    4. Restart Mail, wait for the index to rebuild and retrieve any new email you might have, and see if the problem contineus. Hopefully it will not.

  • AppleScript for Mail

    Is it possible to make an applescript that will check for unread messages through the whole mailbox, then tell me how many there are, then say who each unread mail is from. Ask me to have it read the subject then open, mark as read, or leave for later?

    just like to add in my script based on the above
    i've been looking for something similar to this for a while and tried allsorts of snipets from many of the posts so heres my attempt
    this actually uses the mailbox or folder that is selected in mail.app so you dont have to explicitly tell it which folder you want to use (had that part of the code from another post somewhere so credit to them not me
    display alert "Please note!" message "This script may take a while if you have a lot of mailboxes selected. Do you want to continue?" buttons {"Cancel", "Yes"} cancel button "Cancel"
    tell application "Mail"
              tell front message viewer
                        set theSelectedMailboxes to selected mailboxes
                        repeat with a from 1 to length of theSelectedMailboxes
                                  set theCurrentMailbox to item a of theSelectedMailboxes
      processMailbox(theCurrentMailbox) of me
                        end repeat
              end tell
    end tell
    on processMailbox(theMailbox)
              tell application "Mail"
                        set unread_messages to (messages of theMailbox whose read status is false)
                        set unread_count to count unread_messages
      --display dialog "Total unread messages: " & unread_count
                        repeat with each_message in unread_messages
                                  set the_subject to subject of each_message
                                  set the_sender to sender of each_message
                                  set the_action to choose from list {"Open", "Mark as read", "Keep for later", "Delete"} default items {} with prompt "Subject: " & the_subject & return & return & "Sender: " & the_sender & return & return & "What do you want to do with this message?" & return with title "Unread message" without multiple selections allowed
                                  if the_action is false then return
                                  if item 1 of the_action is "Open" then open each_message
                                  if item 1 of the_action is "Mark as read" then set read status of each_message to true
                                  if item 1 of the_action is "Delete" then
                                            set read status of each_message to true
                                            set junk mail status of each_message to true
                                  end if
                        end repeat
              end tell
              tell application "AppleScript Editor"
      activate
                        display dialog "Do you want to delete the email?" buttons {"yes", "no"} default button 2
                        if result = {button returned:"yes"} then
                                  tell application "Mail"
      # deletes every message that is Read and marked as Junk.
      # Any that are not read AND junk will remain.
                                            delete (every message of theMailbox whose junk mail status is true and read status is true)
                                  end tell
                        else
                                  if result = {button returned:"no"} then
                                  end if
                        end if
              end tell
    end processMailbox

  • ActiveSync Issues - Emails remain unread on iPhones after marked as read in OWA/Outlook

    Environment:
    Exchange 2010 SP2 CU4v2
    iPhones with IOS 6.0+
    Background:
    We've spent a couple weeks troubleshooting this since the vast majority of our users are not experiencing the email synching issue with their mobile devices. However, we have a few users that are remote (international) saying that activesync is not properly
    marking mail as read when initially interacting with it via OWA/Outlook.
    The problem isn't regularly reproducable -- it's sporadic.
    There are two issues really:
    The mail icon indicates X number of unread messages, however when navigating into the mailbox on the phone, nothing is "unread" -- There is only one mailbox -- there is no confusion about unread mail being in a different account.
    Mail marked as read in OWA/Outlook never gets marked as read in the mailbox on the iPhone.
    Steps Taken:
    We've had them remove/readd the activesync account on their device, which initially solves the problem only for it to resuface.
    We've asked them to change their activesync settings between Push, Fetch, and Manual.
    Messages marked as unread always remain unread unless manually opened on the phone. No additional amount of time marks the message as unread unless it is manually opened on the phone.
    We've asked users to try interacting with mail through wifi on a reliable network instead of their cellular network. Same results.
    We don't have any other mobile devices to compare to since everyone is using an iPhone. If only someone had windows mobile.
    Our thoughts are that this is due to some sort of latency issue that activesync is unable to handle, since only these remote users are experiencing the issue. Using in-office wifi the latency between their device and the CAS server is ~250ms. Over cellular
    networks.. unknown. I would think the activesync could handle this.
    Are there any server-side settings that can be changed on the exchange servers that could mitigate these problems?

    Im sure more knowledgeable members will chime in here, but I would say the issue is in ios 6.0 here. The way to test would be if users on previous verison of ios have the same issue. There are various discussions on apples forums regarding ios 6.0 and activesync/
    exchange. Myself personally I have not updated to ios 6.0 and im still using 5.1.1 and Ive not had any exchange/activesync issues. Being a windows user you tend to hold off on major updates / SP releases until the rest of the masses have discovered the flaws.
    Likewise i cant say im keen to jump to ios 6.0 just yet.
    Good read here :
    https://discussions.apple.com/message/19651119#19651119
    Out of interest what happens if you read the email/delete it from the phone ? does it show as being read within Microsoft Outlook ? 
     

  • Mail rule for flagged messages

    Does anyone know a way I could set up a rule so when I flag a read message it moves to a particular folder (mailbox)? Like, I get a "statement to view" message from a credit card company, but I don't have time to see it now, so I flag it and it moves to a folder called "Things to do later", or whatever...

    Yeah, just create a smart mailbox looking for flagged messages.

  • Change selection criteria or check allowance for marking

    Hi,
    I have executed the costing in CK11N and saved the result. The costing run was successful without any error.
    When I want to Mark the cost in CK24, I am getting the below error. Kindly help to resolve this issue.
    Change selection criteria or check allowance for marking
    Message no. CKCC140
    Diagnosis
    No data was selected for marking.
    Possible causes:
    There is insufficient data in the selection screen to select the required cost estimates.
    The organizational measure was not carried out, or it was issued with a different costing variant to that of the cost estimates ( Marking Allowance).
    All the cost estimates contain errors.
    The cost estimates have already been marked or released.
    For detailed information, call up the log.
    thanks and regards
    Murugesan

    Dear Murugesan,
    First ensure in CK11N,you have saved the cost estimate without any error,the signal showing with green colour.
    Then in CK24,first take a test run for marking and then without the check box for test run.
    Before Executing this T Code for marking,click on marking allowance and ensure for the period,company code and the same
    costing variant and costing version,it shows green colour which indicates alloed for marking and release,otherwise,just click on
    your company code,enter the costing variant and costing version and save the datas.
    This should be done only once during the period begining.
    Once after doing this,ensure you have complete authorization for marking and release.
    Check and revert back.
    Regards
    Mangalraj.S

  • Email messages in mailbox marked as read when they arrive on Blackberry

    We are using Outlook Exchange 2007; from yesterday when I added a new email address it is marking messages in the mailbox as read when they arrive on Blackberry 8520 Curve.  Can't for the life of me find the setting to change it and am losing the will to live!  Any help appreciated.

    Hi interferingmother,
    Welcome to the BlackBerry Support Community.
    Is your email account integrated as POP on your BlackBerry® Curve™ 8520 smartphone? If it is, this KB article should provide some ways to resolve this issue. "Email messages on a Microsoft Exchange Server are marked as read when accessed via POP" http://bbry.lv/KvCTaM
    Hope this helps.
    -FS
    Come follow your BlackBerry Technical Team on Twitter! @BlackBerryHelp
    Be sure to click Kudos! for those who have helped you.
    Click Solution? for posts that have solved your issue(s)!

  • Mail 2.0.5 - all my messages are missing after marking as read!!!

    Ok Mail has worked more or less fine for me after upgrading from 10.3.9 to 10.4.3..until a few minutes ago when I decided to mark all the unread messages in my inbox as read. I hadn't read quite a few, so instead of going and clicking on each one, I just selected all, right clicked, and chose Mark as Read. Suddenly they all disappeared, all but a few. I have two inboxes, one on my ISP, and one .mac. Disk Utility says the hard disk is fine, so I rebuilt both inboxes, and now my ISP inbox still just shows a few emails (appears to be the emails I've received since upgrading to Tiger, only a few days' worth), and my .mac inbox now shows about a years' worth of emails...but I know I have more than that, since I've had the .mac account for 2-3 years or so. Also next to the .mac inbox there is some sort of a progress icon (a pie gradually filling in). If I hover the mouse over the .mac account, it says "Contents stored on server. Name on server: INBOX". Which doesn't make sense, since I have always had Mail download the mail from both my accounts, deleting from server after downloading. If I get info on my ISP inbox, it displays "Account Info", and under the Show Messages on POP server, it shows a bunch of messages from about a year ago. But if I pulldown the menu and instead of showing "all messages on POP server" I choose either of the other options ("items downloaded to my Mac" or "items removed from my Mac"), the list is exactly the same.
    My mail appears to be still on my hard drive, since getting info on the various mailbox folders in ~/Library/Mail/ shows about the right amounts of data. I don't want to lose over 300MB (at least 5 years worth) of email....anyone know what could have happened, and more importantly how to fix it?? Thanks!

    Ok after thoroughly searching previous threads about similar problems (existing messages not being displayed by Mail 2.x.x), it appears the 10.4 Archive and Install didn't completely convert the mbox file from my ISP email, since there were only a few emlx files (but there are hundreds of emails in the mbox)...so I had to resort to reimporting it manually. Not sure what happened though to make Mail see all the messages for a few days after installing 10.4.3; there was no error message during the system install, and all I did that prompted all my messages to disappear was to mark all as read...
    As far as the .mac goes, I have no clue where those emails went...I discovered that somewhere along the line my mbox file for .mac account got corrupt...but nothing over a year old is even on the server, which is odd. Those messages apparently are forever lost. Add me to the statistics of why it's important to back up. :/

  • Incoming messages marked as read

    Hi,
    First I'd like to chime in with those who hate that messages are immediately marked as read.
    But here is my real, related, problem; Incoming messages become marked as read in the background. That is; I send myself a message, it comes in as unread. I switch to other apps and work for a while, come back and the new message is marked as read.
    Ah, I just did another test, and found that if I have entourage running also (I'm switching to Mail, have been using Entourage), when it gets the mail, it's marked as read.

    I apologize for being incompetent twice in one message. I've changed my profile. Thanks for pointing it out. I observed the behavior in Mail, so that's where I thought the problem was, (and maybe still is - why should another client affect Mail?). I'm switching from Entourage to Mail, that's why I'm running simultaneously for a few weeks. I've done it many times over the years of operating systems and clients, specifically two years ago when I switched to Apple's Mail, then after finding it lacking, one year ago when I switched back to Entourage. I also often answer email using a browser when I'm not on my machine at home. So I use three methods. I suppose that's wrong too. I noticed the connection between Entourage and Mail halfway through the post, so it turned from a question into a posting that someone else might find useful if they observe the same behavior. But now I know what an idiot I am so everybody ignore this post!

  • Rule to mark sent messages read

    As some other people have noted in the forums, since I've upgraded to Leopard all my sent messages are getting marked as Unread for some reason I gave up trying to understand and/or fix.
    So I was thinking of creating a rule to mark all sent messages as Read.
    How could I accomplish that?

    don't know if this would work but you could try in mail>preferences>rules: "date sent" "is less than" and choose "1", then perform the following... "mark as read".
    rules are applied to incoming messages so that new rule would not automatically apply to your sent mailbox. you would have to go to your sent mailbox once in a while, then select the emails you would like the rule to be applied to, then go to the menu message>apply rules.
    if you have more than one rule and do not want other rules applied to these sent messages, then before applying the rule, you would have to go to mail>preferences>rules and mark as inactive the other rules, leaving only the above one as active.
    a bit tedious workaround i admit and maybe other users may have a more elegant solution.
    hope this helps

  • Applescript for mail error can't get message id

    I have an applescript (found on internet) for Mail 4.5 that deletes messages in "on my mac" mailbox "Deleted Inbox" that are older than 120 days. The script runs from an iCal daily event. I drag messages from Inbox to "Deleted Inbox" when I don't want the message in Inbox, but I want to save the message for 120 days before deleting it. The script sometimes runs successfully, and sometimes gives error "Mail got an error: Can't get message id xxx of mailbox "Deleted Inbox"". Then in Mail, I "Mailbox / Rebuild" that mailbox, and run the script manually without error. How can I avoid that error? The script is essentially:
    tell application "Mail"
              set OldStuff to every message of mailbox TheBox where date received of it < OldDate
              repeat with ThisMessage in OldStuff
        delete ThisMessage
              end repeat
    end tell
    Thanks for any help.
    Ken

    How can I avoid that error?
    I don't actually know how you can avoid that error. However, maybe you can use a workaround and have the script rebuild the mailboxes automatically when such an error occurs. Try the following code:
    tell application "Mail"
      try
        set OldStuff to every message of mailbox TheBox where date received of it < OldDate
      on error
        activate
        tell application "System Events" to click menu item "Rebuild" of menu 1 of menu bar item "Mailbox" of menu bar 1 of process "Mail"
        delay 1 -- adjust if necessary
        set OldStuff to every message of mailbox TheBox where date received of it < OldDate
      end try
      repeat with ThisMessage in OldStuff
        delete ThisMessage
      end repeat
    end tell
    Since the above script uses GUI Scripting, you must enable the Accessibility Frameworks by clicking the checkbox labeled "Enable access for assistive devices" in the Universal Access System Preference pane.
    Message was edited by: Pierre L.

Maybe you are looking for

  • How do I delete my credit card information?

    I'm trying to delete my old credit card information. (I don't have another credit card.) I can't update any of my apps because they continue to ask me for this credit card. I don't even understand why. None of the apps I own are premium. They are all

  • WEB.SHOW_DOCUMENT opens additiional IE browser.

    Hi All, I am using web.show_document (web.show_document('file:///file_name','_blank') ) to open pdf and msg files stored at a location. For PDF files, web.show_document works fine and pdf file gets open. However for msg (email) files, a new browser g

  • FD32 userexit and workflow questions

    Hi All, I need to send an IDOC once changes made in Tcode FD32. I tried to switch on the debugging mode and made some changes so that once I press the save button, i will get into debug mode and look for userexit available but I failed to get any...

  • Exporting Images With Only Specific Metadata

    How do I export images from Aperture with only specific metadata. Example: I want to export my images with only the copyright IPTC metadata (and maybe the keywords or contact info etc., but I don't want the world to see the EXIF data. Aperture manual

  • Lobby Admin for guest account creation - Automation of account creation

    hello all, i'm sure the creation of guest accounts on the lobby admin page is a painful process for all involved - for us, it involves a process like this: visitor asks for wifi > receptionist phones IT > IT creates account> IT phones receptionist wi