Naively thought that would suffice:
tell application "Mail"
move mailbox "complaints" of account "ACME LLC" to mailbox "customers" of account "ACME LLC"
end tell
What's the correct syntax?
Follow up question, how to delete a mailbox?
tell application "Mail"
delete mailbox "complaints" of account "ACME LLC"
end tell
gives me error "AppleEvent handler failed." number -10000"
Ideally, you want to change the folder in which your mailbox is. The mailbox in which you have mailbox is the property 'container'. For instance, container of 'Sub' gives you the mailbox in which mailbox "Sub" is.
Unfortunately, this property is read only in Applescript. So you can't change it ! The work around is to create a new mail box inside your existing mail box and then move the messages between mailboxes.
Your source mailbox is named "Source" and you want to move it inside existing mailbox named "Dest" :
1) create sub mailbox with name "Source" into mailbox "Dest".
tell application "Mail" to set NewBox to make new mailbox with properties {name:"Dest/Source", class:container, unread count:0}
As you can see, Mail event handling here is a bit strange, because the path should be in the name ! fyi, I never succeed to create boxe inside boxe inside boxe. (3 levels) !
Then use the script bellow to move from Source to new "Source"
set BoxeSource to "Source"
set BoxeDest to "Dest/Source"
tell application "Mail" to set mailbox of every message of mailbox BoxeSource to mailbox BoxeDest
Related
I'm using Applescript to automatically draft and send emails in Microsoft Outlook. While everything is working as expected to send emails from my own account, I want to adjust the script to send emails from a different account that I have access to in Outlook. I've found this post, but the approach shown there generates an error for me.
https://macscripter.net/viewtopic.php?pid=185222#p185222
How can I adjust the script below to select the correct mailbox to send my email from? When I use the script below, the following error is generated when I attempt to save it.
Syntax Error
Expected class name but found identified
I've Google this error message, but haven't been able to find anything relevant to my task of changing the account the email is sent from.
set theAccount to the first exchange account whose name is "second.account#company.com"
set recipientAddress to "first.last#company.com"
set theSubject to "This is only a test"
set theContent to "<html><body><p>This is only a test.</p></body></html>"
tell application "Microsoft Outlook"
set newMessage to make new outgoing message with properties {account:theAccount, subject:theSubject, content:theContent}
tell newMessage
make new recipient at newMessage with properties {email address:{address:recipientAddress}}
end tell
save in drafts
end tell
I was wondering if there is a way to mark messages from either a particular thread/user and/or just mark all as read. Preferable per thread. I can see there is a way to do this for the Mail app for example:
on run {}
tell application "Mail"
set read status of every message of mailbox "Deleted Items" of account "MyAccount" to true
end tell
end run
But need to be able to do the same for the Messages App instead.
OSx 10.8.5 Mail 6.6 -
Looked online for years trying to find the REAL solution to this issue. Have IMAPed gmail account. Trying to check for mail in a specific folder/mailbox, however Mac Mail always checks all mailboxes regardless of specifying the specific folder.
Currently using a system events work around to select the mailbox via the favorites shortcut key (limited to 9 possible shortcuts/mailboxes). However I would like a more unlimited and direct solution. See typical code below.
tell application "Mail"
check for new mail of mailbox "Mailbox/Folder Name" of account "Account Name"
repeat until (background activity count) = 0
delay 10
end repeat
end tell
Any ideas?
Thank you.
I'm trying to create an applescript to use on outgoing email messages in Outlook 11 for Mac to dynamically set the email signature in the message based on who the sender address is. I have multiple accounts in Outlook, and would like to change the signature based on which one I'm using. Below is the code I've been trying, but have not had any success. Any advice?
tell application "Microsoft Outlook"
if message sender contains {name:"emailaddress"} then
set the message signature to signature {name:"signaturename"}
else
set the message signature to signature {name:"signaturename2"}
end if
end tell
If I understand your question, I think Outlook 2011 has this capability built in, without the need for any scripting.
Click "Outlook", then "Preferences..." from the Outlook menu
Click the "Signatures" icon
Set up the signatures you need if you haven't already done so, and give them meaningful names
Click the "Default Signatures..." button
Associate the relevant signature to each account that you require
There seems to be a bit of a trick to using this. If you want the signature for account X to appear automatically in a new message, then you must first select a folder from account X before creating a new message. If you do that, then the message should include the correct signature that you have set up for that account.
I have an email that I need to schedule to send later. I know you can schedule an apple script to fire off at a set time using iCal, but I have been unable to find one that works. It doesn't necessarily have to be done this way though. I would be grateful of a solution to this problem.
This works for me with a run script alarm in iCal on 10.6.8
tell application "Mail"
activate
set mymail to make new outgoing message at the beginning of outgoing messages with properties {subject:"Triggered"}
tell mymail
make new to recipient at beginning of to recipients with properties {address:"first#email.com, second#email.com"}
set content to "hi"
end tell
--show message window (otherwise it's hidden)
set visible of mymail to true
--bring Mail to front
activate
send mymail
end tell
I'm also getting an error like outgoing message 1 doesn’t understand the send message when trying to send an outgoing message. Referring to a message created from a script still seems to work though.
tell application "Mail"
set m to make new outgoing message with properties {subject:"subject", content:"content"}
tell m
make new to recipient at end of to recipients with properties {address:"jana#doe.com, john#doe.com"}
end tell
send m
end tell
You could also create a Calendar alarm in Automator.
I just accomplished this without Automator, using only Apple Mail:
Double-click anywhere your calendar to start creating an event.
Give the event a name. This will be the subject line of the email.
Set the date and time of the event to when you want the email to be sent.
If you want the email to be sent on a schedule, choose a repeat frequency and potential termination date.
For the alert, choose Custom....
Select email. You might be prompted to add a contact card to the Contacts app.
Choose the person to whom you want to send the email, and set the time to At Time Of Event. Press OK.
You can choose to add Notes, a URL, or attachments. I haven't tried these options, but I assume that they are carried forward in the email that is sent.