Using AppleScript to auto-archive mail in Outlook 2011
I want to use AppleScript to set up a schedule to auto-archive mail greater than X days old. What I've found so far is below, and the error I'm receiving is "error "Microsoft Outlook got an error: Can’t get pop account \"TargetProcess\"." number -1728 from pop account "TargetProcess"".
# the time we want to archive from
set theArchiveCutoffTime to ((current date) - (32 * days))
property theCount : 0
tell application "System Events"
set targetProcess to count (every application process whose name is "Mail")
end tell
tell application "Microsoft Outlook"
set thisAccount to pop account "TargetProcess"
set thisFolders to mail folder of thisAccount
# find the "Inbox" of topFolder and "Mail ARCHIVE" of on my computer
repeat with thisFolder in thisFolders
if name of thisFolder is "Inbox" then
set theInbox to thisFolder
else if name of thisFolder is "Mail ARCHIVE" then
set theARCHIVE to thisFolder
end if
end repeat
# find the archive "Inbox"
repeat with thisFolder in mail folder of theARCHIVE
if name of thisFolder is "Inbox" then
set theArchiveInbox to thisFolder
end if
end repeat
set theArchiveTarget to theArchiveInbox
# archive the Inbox
repeat with theMessage in message in theInbox
if time received of theMessage < theArchiveCutoffTime then
move theMessage to theArchiveTarget
set theCount to theCount + 1
else
# we get messages from oldest to newest
exit repeat
end if
end repeat
# archive sub-folders
repeat with thisSubfolder in mail folder of theInbox
# find the archive subfolder corresponding to this
repeat with thisARCHIVEubfolder in mail folder of theArchiveInbox
if name of thisARCHIVEubfolder is name of thisSubfolder then
set theArchiveTarget to thisARCHIVEubfolder
end if
end repeat
# archive messages
repeat with theMessage in message in thisSubfolder
if time received of theMessage < theArchiveCutoffTime then
move theMessage to theArchiveTarget
set theCount to theCount + 1
else
# we get messages from oldest to newest
exit repeat
end if
end repeat
end repeat
end tell
I'm working in AppleScript Editor v2.6.1 (152.1), Microsoft Outlook 2011 v14.3.5, OSX 10.9.4 Mavericks.
Ok, red_menace above me had a shorter and more elegant solution to the question, I'm adding this just for another example.
To solve your problem I'd make a mail rule that looked for any messages with "Filename:" in them (along with whatever criteria you wanted, like sender, domain, etc). The mail rule would execute the Applescript. My assumption is that the "Filename:foobar" text could be anywhere in the email, not necessarily the first thing in a paragraph, so I had to parse it differently.
The results end up in a datalist, (theFilename {} ) that you can parse later to collect all filenames found in whatever messages were processed.
I realize this could be cleaner, hope it's not hard to follow, but I did it really fast. It works flawlessly for me, picking out the name of the file no matter where in the email it appears.
using terms from application "Mail"
on perform mail action with messages theSelectedMessages for rule theRule
repeat with aCounter from 1 to count theSelectedMessages
set theMessage to item aCounter of theSelectedMessages
set theContent to content of theMessage
set theWords to every word of theContent
set theFilename to {}
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
repeat with thisLoop in theWords
try
if (text item 1 of thisLoop) is "Filename" then
set end of theFilename to (text item 2 of thisLoop)
-- rest of your logic goes here the display is just to show it finds the filename, take it out!
display dialog theFilename ¬
buttons {"OK"}
end if
end try
end repeat
set AppleScript's text item delimiters to tid
end repeat
end perform mail action with messages
end using terms from
Message was edited by: stephen.bradley Typos for the win!
Similar Messages
-
Has anyone had recent issues with iCloud mail and Outlook 2011?
Two days ago without warning when sending an e-mail from Outlook 2011 from a MacBook Pro running 10.8. (Have a .mac account), I had an error pop up, see below.
Tried entering the password but the same error popped up. Thought there might be an error with the keychain so verified and ran a repair. Still the error continued. I checked that the password was still working and logged into iCloud. I then launched Mac Mail and this worked fine and so also my iPhone / iPad etc. Nothing I did made it possible to send e-maills from my .mac account although I could receive them.
For the last couple of days I have been using my MacBook AIr for sending mails for the same account via Outlook 2011. This has been working fine all day until 25 mins ago when the same error message popped up on this Mac too. Went through the same set of tests and again Mac Mail works and so does the password.
Have tried to Google for a solution but can't find anything relevant. Could this be Microsoft trying to cause problems for Apple users, some rogue update, iCloud security certificate issue, or something more sinister. Any suggestions for a fix gratefully received, as currently I can't use Outlook 2011 on either Mac.Hi guys!
I am also having big trouble syncing my iCloud acc. I am able to send email, but i cannot recieve any. I have tried almost everything. I have tried using p01, p02, p99 servers, without solving the problem. I have tryed typing "INBOX" and "/" in IMAP root, still not working. Have anyone got a solution?
I am using:
OS X 10.9.1
Outlook 2011 for mac v. 14.3.8
I really hope someone has got an answer!
Sorry the text in the screenshots are in danish. I hope you get the idea anyway. -
Apple Mail to Outlook 2011 email migration
I recently decided to shift from Apple Mail to Outlook 2011 because i was not very fond of the preferences used by Apple Mail.
However, it was later on that i realized the migration process from Apple Mail to Outlook 2011 wasn't as easy as i thought i would be.
Now i urgently need to get my important emails transferred, how do i go about it.
Any help will be appreciated.Hey David,
So it would become easier for me to answer your question if you answered any of the following queries-
Do you have:
Any IMAP accounts?
Any Exchange accounts?
Any POP accounts?
Any email stored locally ("On my Mac")? -
UAG problems with OSX - same problem with Mac Mail and Outlook 2011 (via EWS)
Hi folks,
I'm trying to fix the last snagging issue I have with OSX clients in a UAG / Exchange 2010 deployment:
When trying to connect Mac Mail or Outlook 2011 the connections are very slow to start up, both at initial config and thereafter.
On connection I see lots of the same error re Session Cookies in UAG and no connection in the mail client. If I leave it for a few minutes, sometime many minutes, the errors stop and I eventually get a working connection.
The error is:
"Sesson Attempted to Access Restricted Application"
User with source IP address x.x.x.x tried to access application Exchange EWS that was restricted that was restricted for the session. This might indicate an intrusion attempt by misusing the session cookie.
Has anyone got any suggestions on how to fix this ?
Many thanks
SteveRuud, no, we didn't find a solution, or rather our solution (so far) is to tell users not to use Mac Mail and to use Outlook 2011 instead, which seems to work fine (after some Office updates!)...and we haven't upset anyone with that requirement
(yet).
There are some very long discussions on Apple support forums about the whole Mavericks / Mac Mail / Exchange 2010 issues.
I do hope to have another go at this problem sometime soon, I'm sure there must be a solution (and my money says it relates our hardware load balancers).
Steve -
Cant Get Mac Mail ( or Outlook 2011) to connect to Excange erver
When connecting via IPAD it took 30 seconds to set up.
I cant get it running from MAC Mail nor Outlook 2011 for MAC.
Exchange "Server not responding".
It runs great from Outlook Web Access on the mail or from VmWare running Win 7 with Outllok 2007
H E L P !!+1. Me, too. Any solutions? Every few months I spend a lot of time looking for workarounds for this issue. I tried with Mail, and recently I tried the new Microsoft Office. No luck. I work from home and the company I work for uses an exchange server. I'm stuck with Entourage 2008. It's a real bummer.
-
Import apple mails to outlook 2011
Having trouble in moving my mails to outlook 2011 for mac.
Gone through a lot of forums and forum sites but none provided the right solution.
Tried the the IMAP procedure but it takes long time. Don't have that much time to waste.
Have got around 10000 mails and outlook impoet fundtion doesn't seem to work.
Need solutions that can quickly solve this problem of mine.
Waiting for useful help. Thank YouYou can find a queue of solutions if you type the heading of your query in a suitable search engine like google or yahoo.
Basically you will need to convert the apple mail emails that are stored in .emlx format to .olm format that will require a converter tool.
here is one that I think might be helpful: http://mailexporterpro.com/ -
Can't Print E-Mails in Outlook 2011
Why can't I print any e-mails from Outlook 2011? I think this started when I switched to Yosemite. When I print an e-mail from G-Mail, it will print everything except the body of the e-mail. I can print e-mails from my PC using Outlook and G-Mail just fine. Anyone have this problem? Thanks in advance.
Forgot to mention....I have no problem printing Word, Excel or any Web site.
-
Export Apple mail to Outlook 2011 for Mac
Hi everyone,
I don't like the serie Mail/iCal/Carnet d'adresses from Apple, reason why I bought Outlook 2011 for Mac.
I succeed transferring all my contacts to Outlook.
I try now to transfer all my mails with their categories to Outlook too but I don't succeed. I read some discussions on this forum but they are obsolete as they were with snowLeopard and Outlook 2011. Would someone have good news for me and find a way to transfer all the mails with their categories from Apple Mail to Outlook 2011 for Mac ?
It would be nice and to receive a positive answer.
Thank you for your help
RenéeINFORMATION on Emailchemy from another Forum
I’ve found a way in which you can import Apple Mail into Outlook 2011 on Mac OS X Lion.
The software I’m running is Mac OS X 10.7.2 on a 2011 MacBook Pro.
You need to purchase an app called Emailchemy. It’s 29.99 for an individual license, and 49.99 for a family license. There are enterprise versions available as well.
Once you run the app, you need to do the following:
1. Export all mailboxes from Apple Mail to your desktop (or any other suitable location on your computer). You do this by selecting the mailbox, and then clicking on “Mailbox”, and then “Export Mailbox”. Save the destination, and the file is saved automatically.
2. Then you open Emailchemy and do the following:
- click on “toolbox” in the bottom left hand corner
- click on the second box on the top left hand called “advanced email conversion”
- click on “add file”
- select the folder (s) you just exported from Apple Mail (e.g. Inbox.mbox)
Now here comes the trick
- select format “apple mail 1.0 in the format option at the bottom
- then 3 sub-folders will appear “info-p.list”, “mbox” and “table of contents”
Select “mbox”
- click on “convert” and choose a save file name. Choose the format “MBOX file (standard mbox)”
- click on save
And you then have a folder created which Outlook 2011 recognizes and can import.
I just imported all my Apple Mail into Outlook 2011 – it works really well too – the formatting, attachments, etc are all there!
Hope this helps. -
Using PowerShell to auto archive exchange mailboxes to *.pst.
I am trying to auto-archive terminated users' mailbox to *.pst using PowerShell. I use the commandlet, New-MailboxExportRequest. I then type in the the correct file path and mailbox name; however, I keep getting an error indicating that exchange
could not find a database suitable to store my request. Can someone please advise as to how I can remedy this error?Hi,
Please include the full command you ran and the full error text. Also, what version of Exchange are you running?
Don't retire TechNet! -
(Don't give up yet - 12,830+ strong and growing) -
Using Applescript to print calendars in MS Outlook
I print my daily in portrait orientation, with the task list. I like to print my weekly calendar in landscape orientation, without the task list.
I'm new to Applescript and have been poking around in the Outlook library but can't find anything there that indicates how to even just print Calendars using Applescript.
Is there a way to change the page setup to landscape orientation, then print the weekly format (without tasks) and the reset the print orientation to portrait?
Thanks in advance-
Tom
Mac OS 10.6.8You mention using AS to set the preset. Do you know how to do that?
I'm trying to find out how to use a print preset in Applescript on 10.6.7. The only things I've found on the internet suggest running a terminal command that changes the preset, but they are talking about 10.4 and it doesn't work in 10.6. I can't find the answer to this anywhere. It seems like it should be rather simple. -
Applescript to import entourage identity to Outlook 2011
HI everyone,
I was wondering if anyone has had experience or knows the syntax involved in using the applescript commands "import identity" and "import rge" in Outlook 2011 SP1 for Mac.
I've got a script to add the user's Exchange acct into outlook, but am working on automatically importing their Entourage 2004/2008 identity and any .rge archives they may have.
Any ideas? Even if you just know the syntax to use, that would be a huge help. I keep getting thid message on importing an rge:
set TestArchive to "TestArchive.rge"
do shell script "cd /Users/agiadminexec2/Desktop/"
tell application "Microsoft Outlook"
import rge TestArchive
end tell
Response:
tell current application
do shell script "cd /Users/agiadminexec2/Desktop/"
end tell
tell application "Microsoft Outlook"
import rge "TestArchive.rge"
false
end tell
And when I try to import identity:
do shell script "cd '/Users/agiadminexec2/Documents/Microsoft User Data/Office 2004 Identities/'"
tell application "Microsoft Outlook"
import identity "Main Identity"
end tell
Response:
tell current application
do shell script "cd '/Users/agiadminexec2/Documents/Microsoft User Data/Office 2004 Identities/'"
end tell
tell application "Microsoft Outlook"
import identity "Main Identity"
"Microsoft Outlook got an error: Parameter error."Hi,
We can import .iaf files in Outlook 2010 using the following method:
Start Outlook 2010.
On the File menu, click Import and Export.
Click the Advanced tab, and then click Export.
Click Import Internet Mail Account Settings, and then click
Next.
Follow the Internet Connection Wizard to complete the import process.
But, I don't know if we can do this in Outlook for Mac 2011. Since this forum is for general questions and feedback related to Outlook for Windows, it's better to post Mac related issue to the forum for Mac:
http://answers.microsoft.com/en-us/mac/forum/macoutlook?tab=Threads
The reason why we recommend posting appropriately is
you
will
get the most qualified pool of respondents,
and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.
Thank you for your understanding.
Steve Fan
TechNet Community Support -
Export NOTES from Mac Mail to Outlook 2011 for Mac
I have been trying to get Outlook 2011 to work as my primary Mail, Calendar, Notes, and Contacts.
I have only been successful syncing Mail (except for Notes), which it seemed to do on its own, and Contacts where I dragged an exported VCard file to Outlook Contacts. I couldn't get Calendar to import into Outlook so I just recreated the calendar on Outlook. Now Calendar and Mail sync just fine.
Can anyone tell me how to get Notes over to Outlook?
ShermanOutlook for Mac has no option to import from Apple's Mail application. The best suggestion I can offer is that you use an IMAP account to transfer your messages.
Get a free Gmail IMAP account from Google and connect to the account in Mail. Drag your messages into the account to copy them to the server.
Connect to the same account in Outlook and copy your messages from the server to folders under On My Computer.
Another option is to get a third party tool that are available online.
One tool that I am familiar with is Apple Mail Export
Or you can find more on
google or
yahoo for more results
Hope this helps! -
How to create Archiving Rules in Outlook 2011 with Mavericks
I am trying to create an email archive with Outlook 2011 and Mavericks 10.9.2. When I attempt to select the folder I created for the archive, it cannot be found, even after I enter the folder name in the search. Anyone conquer this issue?
Hi Louis Le!
Here is an article that can show you how to create events in Calendar and invite others to it:
Calendar: Invite others to an event
http://support.apple.com/kb/PH11518
Thanks for using the Apple Support Communities!
Cheers,
Braden -
Exporting from Mac Mail to Outlook 2011
Hi,
I want to export all my current mails from Apple Mail into outlook. I am trying to use outlook import function but it doesnot have apple mail/mac mail in its options.
Is there any other way of doing this???Outlook for Mac has no option to import from Apple's Mail application. The best suggestion I can offer is that you use an IMAP account to transfer your messages.
Get a free Gmail IMAP account from Google and connect to the account in Mail. Drag your messages into the account to copy them to the server.
Connect to the same account in Outlook and copy your messages from the server to folders under On My Computer.
Another option is to get a third party tool that are available online.
One tool that I am familiar with is Apple Mail Export
Or you can find more on
google or
yahoo for more results
Hope this helps! -
Revert back to Apple mail from Outlook 2011
I migrated my PST file from Outlook 2010 to the Mac Outlook 2011. In doing so I have discovered that the synching does not work. Is there any way to move my Outlook 2011 back to Apple mail and still retain my folders and emails? I have data that is several years old and need to retain the information. I'm not as concerned about the calendar as I use a 3rd party calendar program. Using Outlook 2011, my contacts and notes do not sync and from what I understand there is no immediate fix. Any thought would be appreciated!
I want to know the easiest way to transfer emails from Ms outlook 2011 to apple mail.
I am stuck in this situation from a very long time and haven't found any solution yet.
Do not want to opt for Imap transfer coz a have thousands of mails to transfer.
Please provide me some smart and easy solutions.
Thanks in advance.
You need to have information about the process to get mbox files from olm files which can be easily accessed over apple platform.
For This you can check this blog, if it can help you:
http://convertolm.wordpress.com/tag/olm-to-mbox/
Stephen Shekh
Maybe you are looking for
-
Uninstalling obiee 11g (11.1.1.3)
Hi, Can any one tell me about uninstalling OBIEE 11g (11.1.1.3). Unfortunately I am unable to find Deinstall or Uninstall option in Start-->Programs-->Oracle Business Intelligence. How can I uninstall it from command prompt or where can I get the dei
-
Migrating from G5 OS 10.4.11 PPC to iMac running Leop. on Intel - problems
Can anyone tell me what problems I will encounter migrating my G5 PPC to a brand new Intel iMac? Various forums give me conflicts (some of the ppc apps will run just fine, some will need to be re-installed [though good luck finding all of the install
-
Do you think i should go to an Apple store to change my battery or go to the store where i bought it?
-
Backups are not working.
Today when I attempted to back up my phone and put some new music on there it did not do it how it should. I connected my phone, opened itunes, selceted my songs and pressed sync. It starts backing up everything on my phone even though there is a res
-
I have faced one of the client interview.... Suppose if come any error comes in FI-SD integration point of view where we can see?( I am give the answer vkoa COA.correct G/L acc.No. sales orgnization, account determination, customer account assignemen