• 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
setting message to unread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

setting message to unread


  • Subject: setting message to unread
  • From: 2551 <email@hidden>
  • Date: Sat, 24 Oct 2015 19:27:58 +0700

Hmm, more Mail mysteries. Wonder if anyone can throw some light on this.

I’ve got a mail rule that calls a numbers spreadsheet and updates it with info from the incoming message. Works just fine. Except…I also want the message to be marked as unread after the spreadsheet has been successfully updated.

I’ve tried two approaches:

1. In the rule, add the condition ‘mark as read’.
Problem: even though I add this condition after the ‘Run AppleScript’ action, it always moves to before it. The result of this is the message gets marked as unread, but my script doesn’t get called any my numbers sheet doesn’t update.

So instead, I tried

2. In the applescript, add the line

 set read status of theMessages to true

just before the end of the "perform action…" handler.
Problem: now the numbers sheet updates, but the message remains as unread.

Any ideas how do I get *both* of these to work together? Where can I put the ‘set read status..' line to make it work?

The whole mail handler looks like this (with some creative substitutions for public posting):

using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
tell application "Mail"

--get customer name from msg content
set this_item to item 1 of theMessages
set theTxt to this_item's content


set ttl to offset of "Price" in theTxt
set pricePaid to rich text ttl thru -1 of theTxt
set theTotal to paragraph 1 of pricePaid
set theNum to rich text 9 thru -1 of theTotal
set theInt to theNum as number
if theInt is greater than 0 then


set fellaMeLad to offset of "Customer" in theTxt
set lessTxt to rich text fellaMeLad thru -1 of theTxt
set ourHouse to offset of "Address" in lessTxt
set stripIt to rich text 1 thru ourHouse of lessTxt



--get the email address from msg content
set theParagraphs to paragraphs of stripIt
set theCustard to paragraph 3 of stripIt
set theEmail to paragraph 4 of stripIt
if theEmail does not contain "@" then
set theEmail to paragraph 5 of stripIt
end if


-- get the product from the subject line
set theSubjectLine to this_item's subject
set theProdNum to offset of theCustard in theSubjectLine
set lessSubjectLine to rich text theProdNum thru -1 of theSubjectLine
set removeCustard to offset of "- " in lessSubjectLine
set theSubjectLine to rich text (removeCustard + 2) thru -1 of lessSubjectLine
set gotProduct to 0


-- oh if only we had switch and case...
set theSource to ""
if theSubjectLine contains “blah blah" then
set theSource to “blah"
set gotProduct to 1
end if

if theSubjectLine contains “blob blob" then
set theSource to “blob"
set gotProduct to 1
end if


if theSubjectLine contains “bling bling" then
set theSource to “bling"
set gotProduct to 1
end if


if theSubjectLine contains “blam blam" then
set theSource to “blam"
set gotProduct to 1
end if


if gotProduct = 0 then
set theSource to "Unknown Product"
end if


my letsDoNumbers(theSource, theCustard, theEmail)
— everything works OK up to this point, however...

—this doesn’t work:
set read status of theMessages to true
end if
end tell

—putting it here instead doesn’t work either:
#set read status of theMessages to true
end perform mail action with messages
end using terms from



Best


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

  • Follow-Ups:
    • Re: setting message to unread
      • From: Yvan KOENIG <email@hidden>
    • Re: setting message to unread
      • From: Christopher Stone <email@hidden>
    • Re: setting message to unread
      • From: 2551 <email@hidden>
  • Prev by Date: Mail: preview pane is visible
  • Next by Date: Re: setting message to unread
  • Previous by thread: Re: Mail: preview pane is visible
  • Next by thread: Re: setting message to unread
  • Index(es):
    • Date
    • Thread