Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rate Thread Display Modes
Old 10-25-2010, 01:29 AM   #1
FortuitousForty
Prospect
 
Join Date: Jul 2009
Posts: 4
Applescript to create new remote mailbox on IMAP server in Mail.app

Hi!

I'm endeavoring to create an Applescript that can create a new, nested mailbox (aka "folder") on the remote MobileMe server.

So far, this is what I have:

Code:
set parent_mailbox to "Happy"
set child_mail_box to "GoLucky"

tell application "Mail"

	-- Check to see if this mailbox does not exist.
	if not (exists mailbox (parent_mailbox & "/" & child_mail_box) of account "MobileMe") then
	        --trying to create the new mailbox
		make new mailbox with properties {name:parent_mailbox & "/" & child_mail_box} of account "MobileMe"
	end if
end tell
Let me break this down:
1) On the MobileMe IMAP mailbox list, check to see if the mailbox "GoLucky" already exists under the currently-existing mailbox called "Happy"
2) If it does exist, exit.
3) If it does not exist, create a new mailbox and name it "GoLucky" under the currently-existing remote mailbox named "Happy"

I can get Applescript to create a new, non-nested, LOCAL mailbox, but I'd like to create a new, nested mailbox on the REMOTE server.

Any ideas?
FortuitousForty is offline   Reply With Quote
Old 12-31-2010, 02:39 PM   #2
FortuitousForty
Prospect
 
Join Date: Jul 2009
Posts: 4
I figured it out...

Code:
set parentMailbox to "Happy"
set childMailbox to "GoLucky"

tell application "Mail"
	tell account "MobileMe"
		if not (exists mailbox (parentMailbox & "/" & childMailbox)) then
			set mbox to make new mailbox with properties {name:parentMailbox & "/" & childMailbox}
		end if
	end tell
end tell
Simple.
FortuitousForty is offline   Reply With Quote
Old 12-31-2010, 05:27 PM   #3
renaultssoftware
MVP
 
Join Date: Dec 2009
Location: Pembroke, Ontario
Posts: 2,051
Good job FF!
__________________
Get Icon Creator and support me.
renaultssoftware is offline   Reply With Quote
Reply

Tags
applescript, imap, mail.app, mailbox, nested

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 02:28 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.