Jump to content

Workflow for Outlook V16 Search


Recommended Posts

Posted (edited)

I create a workflow for searching mail from Outlook for Mac V16 (A.K.A. 2016).

Now it support searching Mail sender, Subject and Preview Content with below format:

olk [keyword]

And also you can search with multiple keywords:

olk [keyword1] [keyword2] [keyword3]

To limit search scope in one attribute:

olk from:[keyword]

olk title:[keywords1] [keywords2] ...

2018-03-08_15-10-24.jpg.1ebd4c5dff77b6f0264d50f985f06a2b.jpg

 

By default, this workflow searches mail from all folders and with default page size 20, for results more than 20, you can click last item 'Next 20 Results...' to go to next page.

You can also configure the search:

olkc pagesize [number] 

for change search result in one result list.

olkc folder

then you can get a list of all your Outlook folders, choose one to limit search scope.

 

 

Project hosted in Github:

https://github.com/xeric/alfred-outlook

Download latest release workflow file from:

https://github.com/xeric/alfred-outlook/releases

 

Welcome your feedbacks!

Edited by xeric
  • 10 months later...
  • 2 weeks later...
Posted

@Joe O. Please follow below step to get some debug log, then I may dig into what happens:

* goto Alfred Preferences -> Workflows and choose Outlook Search in sidemenu
* click most right 'bug' icon button in main windows toolbar to step into debug mode
* try to trigger Alfred input with your hotkey and input text and something else (at least three characters), you will get some debug information in debug console.

 

Please anonymize some sensitive information in debug info you got.

 

In your case, there may be something wrong with the database path, what you will see in debug log something like:

/Users/{yourAccount}/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/

try to access this path you your local file system and check if the path is existing or not.

Posted

@xeric Thank you for the reply and offer to help!

 

I followed the instructions above and for some reason, I get no debug output... after 10-20 min it still reads "Starting debug for 'Outlook Search'"

 

Any ideas?

 

Posted

Starting debug for 'Outlook Search' means debug is started, and waiting for your workflow run.

Did you try to call out alfred with hot key and input for example "olk test" after you enable debug?

Posted (edited)

Oh... LOL. Thank you!! Here it is:

 

 

Starting debug for 'Outlook Search'

 

[2019-02-22 08:04:11][STDERR: input.scriptfilter] 08:04:11 workflow.py:1689 DEBUG    loading cached data: /Users/JOE/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.xericwei.alfred/__workflow_update_status.cpickle

08:04:11 workflow.py:2269 DEBUG    update_data: {u'available': False}

.

08:04:11 workflow.py:2055 DEBUG    ---------- Outlook Search (0.1.0) ----------

08:04:11 workflow.py:1462 DEBUG    reading settings from /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/settings.json

08:04:11 workflow.py:2339 DEBUG    update check not due

08:04:11 main.py:34 INFO    searching mail with keyword

08:04:11 workflow.py:2248 DEBUG    set last run version: 0.1.0

08:04:11 workflow.py:2097 DEBUG    ---------- finished in 0.036s ----------

[2019-02-22 08:04:11][STDERR: input.scriptfilter] 08:04:11 workflow.py:1689 DEBUG    loading cached data: /Users/JOE/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.xericwei.alfred/__workflow_update_status.cpickle

08:04:11 workflow.py:2269 DEBUG    update_data: {u'available': False}

.

08:04:11 workflow.py:2055 DEBUG    ---------- Outlook Search (0.1.0) ----------

08:04:11 workflow.py:1462 DEBUG    reading settings from /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/settings.json

08:04:11 workflow.py:2339 DEBUG    update check not due

08:04:11 main.py:34 INFO    searching mail with keyword

08:04:11 workflow.py:2248 DEBUG    set last run version: 0.1.0

08:04:11 workflow.py:2097 DEBUG    ---------- finished in 0.025s ----------

[2019-02-22 08:04:11][ERROR: input.scriptfilter] Code 1: 08:04:11 workflow.py:1689 DEBUG   loading cached data: /Users/JOE/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.xericwei.alfred/__workflow_update_status.cpickle

08:04:11 workflow.py:2269 DEBUG    update_data: {u'available': False}

.

08:04:11 workflow.py:2055 DEBUG    ---------- Outlook Search (0.1.0) ----------

08:04:11 workflow.py:1462 DEBUG    reading settings from /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/settings.json

08:04:11 workflow.py:2339 DEBUG    update check not due

08:04:11 main.py:51 INFO    /Users/JOE/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/

08:04:11 main.py:63 INFO    query string is: kat

08:04:11 main.py:64 INFO    query page is: 0

08:04:11 workflow.py:1579 DEBUG    data `pagesize` stored as `cpickle`

08:04:11 workflow.py:1594 DEBUG    stored data loaded: /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/pagesize.cpickle

08:04:11 workflow.py:1565 DEBUG    no data stored for `folder`

08:04:11 workflow.py:2074 ERROR    unable to open database file

Traceback (most recent call last):

  File "/Users/JOE/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.88E5C3CF-CD49-4826-9B12-DC868CC4938C/workflow/workflow.py", line 2067, in run

    func(self)

  File "main.py", line 32, in main

    handle(wf, query)

  File "main.py", line 91, in handle

    con = sqlite3.connect(outlookData + 'Outlook.sqlite')

OperationalError: unable to open database file

08:04:11 workflow.py:2097 DEBUG    ---------- finished in 0.027s ----------

[2019-02-22 08:04:12][ERROR: input.scriptfilter] Code 1: 08:04:11 workflow.py:1689 DEBUG   loading cached data: /Users/JOE/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.xericwei.alfred/__workflow_update_status.cpickle

08:04:11 workflow.py:2269 DEBUG    update_data: {u'available': False}

.

08:04:11 workflow.py:2055 DEBUG    ---------- Outlook Search (0.1.0) ----------

08:04:11 workflow.py:1462 DEBUG    reading settings from /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/settings.json

08:04:11 workflow.py:2339 DEBUG    update check not due

08:04:11 main.py:51 INFO    /Users/JOE/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/

08:04:11 main.py:63 INFO    query string is: kati

08:04:11 main.py:64 INFO    query page is: 0

08:04:11 workflow.py:1579 DEBUG    data `pagesize` stored as `cpickle`

08:04:11 workflow.py:1594 DEBUG    stored data loaded: /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/pagesize.cpickle

08:04:11 workflow.py:1565 DEBUG    no data stored for `folder`

08:04:11 workflow.py:2074 ERROR    unable to open database file

Traceback (most recent call last):

  File "/Users/JOE/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.88E5C3CF-CD49-4826-9B12-DC868CC4938C/workflow/workflow.py", line 2067, in run

    func(self)

  File "main.py", line 32, in main

    handle(wf, query)

  File "main.py", line 91, in handle

    con = sqlite3.connect(outlookData + 'Outlook.sqlite')

OperationalError: unable to open database file

08:04:11 workflow.py:2097 DEBUG    ---------- finished in 0.027s ----------

[2019-02-22 08:04:14][ERROR: input.scriptfilter] Code 1: 08:04:14 workflow.py:1689 DEBUG   loading cached data: /Users/JOE/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/com.xericwei.alfred/__workflow_update_status.cpickle

08:04:14 workflow.py:2269 DEBUG    update_data: {u'available': False}

.

08:04:14 workflow.py:2055 DEBUG    ---------- Outlook Search (0.1.0) ----------

08:04:14 workflow.py:1462 DEBUG    reading settings from /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/settings.json

08:04:14 workflow.py:2339 DEBUG    update check not due

08:04:14 main.py:51 INFO    /Users/JOE/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/

08:04:14 main.py:63 INFO    query string is: katie

08:04:14 main.py:64 INFO    query page is: 0

08:04:14 workflow.py:1579 DEBUG    data `pagesize` stored as `cpickle`

08:04:14 workflow.py:1594 DEBUG    stored data loaded: /Users/JOE/Library/Application Support/Alfred 3/Workflow Data/com.xericwei.alfred/pagesize.cpickle

08:04:14 workflow.py:1565 DEBUG    no data stored for `folder`

08:04:14 workflow.py:2074 ERROR    unable to open database file

Traceback (most recent call last):

  File "/Users/JOE/Library/Application Support/Alfred 3/Alfred.alfredpreferences/workflows/user.workflow.88E5C3CF-CD49-4826-9B12-DC868CC4938C/workflow/workflow.py", line 2067, in run

    func(self)

  File "main.py", line 32, in main

    handle(wf, query)

  File "main.py", line 91, in handle

    con = sqlite3.connect(outlookData + 'Outlook.sqlite')

OperationalError: unable to open database file

08:04:14 workflow.py:2097 DEBUG    ---------- finished in 0.026s ---------so

 

Edited by Joe O.
Posted

Thanks for this debug information, could you please check if below file/path exists?

/Users/JOE/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/Outlook.sqlite

 

From the error you provided, includes screenshot, they pointed to the database file is not existing.

Posted

Ok. I think we're getting closer!

 

This is what I see

 

/Users/JOE/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/JOE/Data/Outlook.sqlite

 

and

 

/Users/JOE/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/JOE2/Data/Outlook.sqlite

 

The JOE profile shows:

 

image.png.933841a41307abda85e6a214d36e5926.png

 

And the JOE2 profile shows:

 

image.png.595def7b022da4f1c952c3e4d113cb9d.png

 

Clearly, JOE2 is the correct and current profile. What do I do to point Aldred at this one?

Posted

I see, then I think my workflow did not support point to other profile folder than default one - 'Main Profile'.

Please give me some time, I will find how to support non-default profile in next release.

Before that, if you hope to use this workflow, here's a 'hack' workaround for my workflow:

* goto Alfred Preferences -> Workflows and choose Outlook Search in sidemenu

* right click on Outlook Search item and choose Open in Finder

* You can see in Finder, there are some *.py files, select main.py and use a text editor open it

* In opened file, around 50# line (if it is latest version, it is exactly 50#), it is:  

outlookData = homePath + r'/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/'

now, change 'Main Profile' to 'JOE2', save it, now you have your own hacked and worked version😏

 

Posted

I just did that... and it's still not working.

 

Here is the debug

 

Starting debug for 'Outlook Search'

[2019-02-25 07:49:42][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:43][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:43][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:43][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:43][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:43][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:47][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:47][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:47][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:48][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:48][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8
[2019-02-25 07:49:49][ERROR: input.scriptfilter] Code 1: File "main.py", line 1
SyntaxError: encoding problem: uff-8

Posted

@DADIAODIAO Finder can't perform title based, sender based or folder based accurate search, Finder can't display some preview content, beside that if you are searching some history mail, this workflow supports pagination.

Posted (edited)

@Joe O. I released version 0.1.1, now it supports configure non-default profile (account), you can use 'olkc profile' to list all available profiles, then you can select and set your default profile.

Edited by xeric
  • 2 weeks later...
Posted

Hi, Could you pls post screenshots of preview of Outlook emails? Can I also preview the attachment in that email? If yes, pls post screenshots of them as well. I am not a powerpack user in Alfred. If this works I may go in for powerpack. Hence, this info will help me decide.

Posted

@PS_Mac you just can see a little preview content in subtitle in result list - like what you saw in my screenshot, and there's no attachment preview functionality, you have to open the mail by click enter on result and open it in outlook to take a look.

Posted (edited)

@xeric

 

I just got an update that broke the workflow again. Now it's pulling from an older profile and doesn't see my current profile.

 

Line 50 of the main.py file reads:

 

   outlookData = homePath + OUTLOOK_DATA_PARENT + profile + OUTLOOK_DATA_FOLDER
        log.info(outlookData)

 

When it used to read:

 

outlookData = homePath + r'/Library/Group Containers/UBF8T346G9.Office/Outlook/Outlook 15 Profiles/Main Profile/Data/'

 

Any recommendations on a fix?

Edited by Joe O.

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...