• 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
Re: How do I target Junk in Apple Mail?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I target Junk in Apple Mail?


  • Subject: Re: How do I target Junk in Apple Mail?
  • From: Yvan KOENIG via AppleScript-Users <email@hidden>
  • Date: Wed, 15 Apr 2020 21:25:20 +0200

It's what I get if I ask for a mailbox which doesn't exist.

tell application "Mail"
        set junkBox to (first mailbox whose name is "DonaldTrump")
        --> error "Erreur dans Mail : Il est impossible d’obtenir mailbox 1
whose name = \"DonaldTrump\". Index non valable." number -1719
end tell

Here is a script which would help you to find what is wrong on your side.

----------------------------------------------------------------
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions
----------------------------------------------------------------
property |⌘| : a reference to current application


tell application "Mail"
        set boxNames to name of every mailbox
end tell
set boxNames to my sortList:boxNames
set theBox to choose from list boxNames
if theBox is false then error number -128
set theBox to item 1 of theBox

set descriptors to {}
set theCharacters to text items of theBox
repeat with aChar in theCharacters
        set end of descriptors to {aChar as string, id of aChar}
end repeat

tell application "Mail"
        properties of (first mailbox whose name is theBox) -- Yes, when there
is such mailbox, the script get it
        --> {account:missing value, name:"Junk", container:account id
"30ACBF46-881C-40AC-B33B-500D53832270", class:container, unread count:0}
end tell

{theBox, descriptors}
(*
{"AscriptUS 2005_05", {{"A", 65}, {"s", 115}, {"c", 99}, {"r", 114}, {"i",
105}, {"p", 112}, {"t", 116}, {"U", 85}, {"S", 83}, {" ", 32}, {"2", 50}, {"0",
48}, {"0", 48}, {"5", 53}, {"_", 95}, {"0", 48}, {"5", 53}}}

{"Junk", {{"J", 74}, {"u", 117}, {"n", 110}, {"k", 107}}}

*)
#=====

on sortList:aList
        set theArray to |⌘|'s NSArray's arrayWithArray:aList
        set theArray to theArray's
sortedArrayUsingSelector:"localizedStandardCompare:"
        return theArray as list
end sortList:

#=====

> Le 15 avr. 2020 à 20:25, Jim Krenz <email@hidden> a écrit :
>
> Interesting, but it gives me an error:
>
> error "Mail got an error: Can’t get mailbox 1 whose name = \"Junk\". Invalid
> index." number -1719
>
> Ideas?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi
15 avril 2020  21:19:43




 _______________________________________________
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

References: 
 >How do I target Junk in Apple Mail? (From: Jim Krenz via AppleScript-Users <email@hidden>)
 >Re: How do I target Junk in Apple Mail? (From: Yvan KOENIG via AppleScript-Users <email@hidden>)
 >Re: How do I target Junk in Apple Mail? (From: Jim Krenz via AppleScript-Users <email@hidden>)

  • Prev by Date: Re: How do I target Junk in Apple Mail?
  • Next by Date: Re: How do I target Junk in Apple Mail?
  • Previous by thread: Re: How do I target Junk in Apple Mail?
  • Next by thread: Re: How do I target Junk in Apple Mail?
  • Index(es):
    • Date
    • Thread