Related Article

Use AppleScript to automate tasks in iWork for Mac

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Question:

Question: Applescript to select the message from Imap folder in Mail.app

I need to write an Applescript for Mail.app that will export messages' subjects into an excel worksheet.

The closet code I found online which could do this is as following:

tell application "Microsoft Excel"
set theSpamFile to make new workbook
set theSheet to active sheet of theSpamFile
set formula of range "B1" of theSheet to "Subject"
set formula of range "A1" of theSheet to "From"
end tell
tell application "Mail"
set theRow to 2
get mailboxes
set theMessages to messages of junk mailbox
repeat with aMessage in theMessages
my SetFrom(sender of aMessage, theRow, theSheet)
my SetSubject(subject of aMessage, theRow, theSheet)
set theRow to theRow + 1
end repeat
end tell
on SetFrom(theSender, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "A" & theRow
set formula of (range theRange) of theSheet to theSender
end tell
end SetFrom
on SetSubject(theSubject, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "B" & theRow
set formula of range theRange of theSheet to theSubject
end tell
end SetSubject

These code work fine for the Mailbox junk.

But I don't know how to manipulate the code to select messages within a subfolder of a Imap account in Mail.app.

I have several Imap account in Mail.app. Two gmail account, one iCloud account and etc. I have also created folds and subfolders under each Imap account.

I want to export the unread messages from the subfolder: it is located at "Google/Supplier/SupplierUpdate"

I have tried to change the selecting line from

   set theMessages to messages of junk mailbox
to
     set theMessages to messages of mailbox"[Google]/DobaSupplierUpdate/DobaCancellation"
But the script editor keep showing the following message:
     Mail got an error: Can’t get mailbox "[Google]/DobaSupplierUpdate/DobaCancellation".
Any help to point me in the right direction?

MacBook Pro, iOS 11.1

Posted on

Reply

Page content loaded

There are no replies.
User profile for user: ivici

Question: Applescript to select the message from Imap folder in Mail.app