Jump to content

introducing alfred-outlookSuite 📬, a suite of tools to interact with Microsoft Outlook via Alfred


Recommended Posts

Download

image.thumb.png.c726f87fe10131838bc1214fc0ad19dc.png

Motivation

- Quickly list, search, and filter your Microsoft Outlook emails 
- Perform basic tasks like: email snoozing, quick email drafting, email saving. 

 

Note: Many of the functions of this package will not work with the new, electron-based, New Outlook interface, as AppleScript is not supported. Uncheck New Outlook in the File menu in Outlook to switch to the previous version.

 

Basic Usage 📖

Search your email 🔍

- standard search: one or more search strings will search both the subject of an email, and its preview (first 250 characters). 
- gmail-like search strings, listed below, supported (remember to set the MYSELF variable in the Workflow Configuration). 
    - from: (including from:me). Replace space with underscore if you want to specify the whole name (e.g. from:john_appleseed)
    - to: (including to:me)
    - cc: (including cc:me)
    - subject:has:attach, is:unread, is:read, is:important, is:unimportant  
    - folder: (note: replace spaces with underscores if the folder name contains spaces, e.g. folder:sent_items)
    - -text to exclude text 
    - --a to sort by increasing date (oldest first)
    - since:n will return email received in the last n days. w and m are supported for months and weeks, respectively (e.g. since:2w).
- Once an email of interest has been identified, the following actions are possible:
    - ↩️Enter will open the email in Outlook
    - ^-↩️ (control-enter) will show all the messages in the thread
    - ⇧-↩️ (shift-enter) will show in large font (and copy to clipboard) the following fields from the message: From, To, Subject, and Preview from the selected email. 
 
Draft a new email
- use a keyword (default: em) or a hotkey to launch, followed by text. Alfred will create a draft email with subject =  entered text, and save it  in the Drafts folder. 

 

Email Saving 💾
- use a keyword (default: ols) or a hotkey to launch, while Outlook is the frontmost application and an email is selected. 
- Choose the destination folder using Alfred's file filter
- Save your email there. File will be renamed to include date and exclude special characters. A Markdown link to that email is copied to the clipboard. 

 

Email Snoozing 💤
- Make sure you have, or create, a Snoozed folder in your main Outlook account. 
- use a keyword (default: olz) or a hotkey to launch, while Outloook is the frontmost application and an email is selected. 
- enter the number of days you want to snooze your email. Alfred will show the corresponding date, and the number of emails already snoozed for that date. 
- Selecting the result will 1) Snooze the email until the desired date and 2) move that email to the Snoozed folder. 
- the checkSnoozed keyword will show in large font (and copy to clipboard) an overview of all the snoozed email (one line per day) 
- Unsnoozing will happen once a day, as soon as alfred-outlookSuite is launched. You can force the unsnooze script using a keyword (default: olu) or a hotkey).

 

Feedback welcome!

Link to comment

thanks for the feedback @TomBenz. Ideas for improvement always welcome. 

 

Re multiple accounts, I can't test this because I only have one... Would they show as separate folders in ~/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/, in addition to Main Profile? If so, I can easily add the option of specifying which profile to use. 

 

Re nested folders, have you tried to search in the nested one (e.g. if the mail is in Folder/NestedFolder, search with folder:NestedFolder)? It should work. 

Link to comment
3 minutes ago, giovanni said:

thanks for the feedback @TomBenz. Ideas for improvement always welcome. 

 

Re multiple accounts, I can't test this because I only have one... Would they show as separate folders in ~/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/, in addition to Main Profile? If so, I can easily add the option of specifying which profile to use. 

 

Re nested folders, have you tried to search in the nested one (e.g. if the mail is in Folder/NestedFolder, search with folder:NestedFolder)? It should work. 

 

1. Account

Profile is same and under main profile. the folder structure at ~/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/ seems complex. There are main folder caches, local files etc. See you are searching main profile, all accounts are getting searched which is good and desirable. I have common folder name in different accounts and want to see if I can check specific account.

 

Pls see if you can add a dummy account such as Gmail to review this further.

 

I can use this AppleScript code to get account list: 

 

 

tell application id "com.microsoft.Outlook"

set theAccounts to get imap accounts

set ExchangeAccounts to get exchange accounts

set theAccounts to theAccounts & ExchangeAccounts

 

set accountInfo to {}

repeat with theAccount in theAccounts

set end of accountInfo to "New account"

set end of accountInfo to "Name: " & name of theAccount

set end of accountInfo to "Username: " & user name of theAccount

end repeat

return accountInfo

end tell

 

2. Nestedfolder:

Yes, NestFolder works as well as Folder. I have some common folder name in different account. I will test if it searches both.

 

3. SmartFolders -- is there a way to go to this and search further with additional criteria.

 

for example, SF:largemails and then from: etc.

 

4. For exact search such as name, should it be set to FirstName_LastName or is it possible to use "FirstName LastName" which is more natural and regular way to do exact search?

 

Overall this is a great workflow. 

Link to comment

 

1 hour ago, TomBenz said:

want to see if I can check specific account.

try this version (you will need to refresh the database with outlook::refresh or your custom keyword. Use the account:xxx syntax, where xxx are the first letters of the account. 

 

1 hour ago, TomBenz said:

SmartFolders

As far as I can tell, those are just saved queries. One could set saved queries in Workflow Configuration, like: sf1 = from:me has:attachment, and then use them in search with sf:sf1

 

1 hour ago, TomBenz said:

is it possible to use "FirstName LastName"

I need the underscore (or any other character) to keep the element together, otherwise it will search for LastName as a separate string. One possibility is to have an autocomplete-like feature, which will let you select the contact name as you type, but that would only work with saved contacts. Or, I could take all the names from the email database and generate an empirical list of contacts from which the user can choose... 

 

 

Link to comment
2 hours ago, giovanni said:

 

try this version (you will need to refresh the database with outlook::refresh or your custom keyword. Use the account:xxx syntax, where xxx are the first letters of the account. 

 

Tested. Many thanks for the update. it works great.

 

2 hours ago, giovanni said:

As far as I can tell, those are just saved queries. One could set saved queries in Workflow Configuration, like: sf1 = from:me has:attachment, and then use them in search with sf:sf1

 

How to save these queries? Should I use snippets otherwise?

 

2 hours ago, giovanni said:

I need the underscore (or any other character) to keep the element together, otherwise it will search for LastName as a separate string. One possibility is to have an autocomplete-like feature, which will let you select the contact name as you type, but that would only work with saved contacts. Or, I could take all the names from the email database and generate an empirical list of contacts from which the user can choose... 

 

 

 

Search by keyword or subject will serve most of search requirements. can manage with contact name as it is.

Link to comment

@TomBenz I have tried in this new beta version to implement contact autocomplete and saved queries. 

 

Contact autocomplete: in Workflow Configuration, you can choose between None (no autocomplete), AddressBook (autocomplete list based on the contacts in your address book), and 3) Database (autocomplete list generated based on the senders in the database, which is more complete, but can get messy). If not None, autocomplete is triggered by from: and to:.

 

Saved queries: they can be entered in Workflow configuration, with this format: RecentUnread = to:me is:unread since:20. Multiple saved queries can be ; separated. Triggered by sq:.


Let me know what you think!

Link to comment
2 hours ago, giovanni said:

@TomBenz I have tried in this new beta version to implement contact autocomplete and saved queries. 

 

Contact autocomplete: in Workflow Configuration, you can choose between None (no autocomplete), AddressBook (autocomplete list based on the contacts in your address book), and 3) Database (autocomplete list generated based on the senders in the database, which is more complete, but can get messy). If not None, autocomplete is triggered by from: and to:.

 

Saved queries: they can be entered in Workflow configuration, with this format: RecentUnread = to:me is:unread since:20. Multiple saved queries can be ; separated. Triggered by sq:.


Let me know what you think!

 

1. This is interesting. I am getting this error for simple search. 

[05:38:38.052] ERROR: Outlook Suite[Script Filter] Code 1: [{'Name': 'RecentUnread', 'Query': 'to:me is:unread since:20'}]
1 days from last update.

 

2. Update of workflow is not saving keywords or addition done for variable MYSELF etc. Pls look into it.

Link to comment

1. Contact search -- it is amazing. many many thanks.

- I used Database option as my contacts are in the contacts application instead of Outlook itself.

- AddressBook option - is it taking it from Outlook contacts or macOS contacts? I think 2nd as I only get one contact in my Outlook contact. I use iCloud Contact and macOS contacts instead of exchange contacts.

- How to tell search not to search for contact name i.e. search for email from:contact that are not in database? It gives Matched query fail error. i.e. how to go back to contact:none option.

 

2. Saved queries os sq: gives one saved queries. Tried saving more queries by query followed by; in Alfred dialog but it doesn't save or give any message. In saved queries, from:contact gives the same drop down but the query fails though it is a valid search.

Edited by TomBenz
Link to comment
On 6/9/2023 at 3:28 PM, giovanni said:

can you share the string you entered (the content of the Workflow Configuration box named Saved Queries) and the debugger output? 

@giovanniGiovanni -- are we supposed to add queries in workflow configuration? is it that we just enter ";" in Alfred box at the end to indicate workflow to save queries? 

 

How many queries can be saved? Is it possible to add 3-4 default examples sq2: is:read has:attach or sq3: from:FName_LName

 

 

Link to comment
2 hours ago, TomBenz said:

are we supposed to add queries in workflow configuration?

yes, ; separated, and = instead of :. for example for your 2 saved queries you would enter in Workflow Configuration:
sq2 = is:read has:attach; sq3 = from:FName_LName, then you would see them triggered by sq:

image.thumb.png.ddf41af6a17192da23c3e2ff9875064b.png

 

Link to comment
4 hours ago, leeleblanc said:

Anyway to be able to get the body of the draft message filled in along with the Subject line?

yes, how would you envision that? For example with a separator (e.g. ///), like this:  this is my subject///this is my text body

Link to comment
  • 1 month later...
  • 1 month later...

Hi,

 

I'm trying to use this workflow within Alfred, and i am able to make a draft email. However i am not able to search my Outlook folders.

If i use the debug option it states:

 

File "/Users/Mark/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.91329CD4-92F2-4663-86BF-C12EAF354D81/util.py", line 78, in getFolderData
    db = sqlite3.connect(OUTLOOK_DB_FILE)
sqlite3.OperationalError: unable to open database file

 

Also when i type OL it will then replace it with OLK and Alfred wants to search on the internet.

 

Can someone help me out? 

Link to comment
On 8/25/2023 at 12:28 PM, Mark van Mullem said:

Hi,

 

I'm trying to use this workflow within Alfred, and i am able to make a draft email. However i am not able to search my Outlook folders.

If i use the debug option it states:

 

File "/Users/Mark/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.91329CD4-92F2-4663-86BF-C12EAF354D81/util.py", line 78, in getFolderData
    db = sqlite3.connect(OUTLOOK_DB_FILE)
sqlite3.OperationalError: unable to open database file

 

Also when i type OL it will then replace it with OLK and Alfred wants to search on the internet.

 

Can someone help me out? 

Hey,

You need to do the following:

 

Open the Workflow in Finder

Replace the line in the consts.py document that says "/Users/giovanni/Desktop/Main Profile/Data/Outlook.sqlite" with your own path for your Outlook.sqlite file. (Try looking here: /Users/<username>/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/Outlook.sqlite.
Then run the outlook::refresh command from Alfred and it should say done.

 

Hope it works.

 

Ta-da!

 

Craig

Link to comment
  • 2 weeks later...
  • 4 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...