use Python and an outlook: protocol URL to bring up a specific email

jkn jkn_gg at nicorp.f9.co.uk
Tue Jan 12 12:22:26 EST 2016


Hi Chris

On Tuesday, January 12, 2016 at 5:11:18 PM UTC, Chris Angelico wrote:
> On Wed, Jan 13, 2016 at 3:51 AM, jkn <jkn_gg at nicorp.f9.co.uk> wrote:
> > I happy to carve some code without using urllib, but I am not clear what I
> > actually need to do to 'open' such a URL using this protocol. FWIW I can paste
> > this URL into Windows Explorer and I get the referenced email popping up ;-)
> >
> 
> What happens if you invoke the 'start' command using subprocess?
> 
> subprocess.check_call(["start", url])
> 
> In theory, that should be equivalent to pasting it into Explorer. In theory.
> 
> ChrisA

I'll try that, but (typically!) I found some things that worked shortly after
posting... 

These both work:

PROTOCOL = "outlook:"
TEST_URL = "00000000BB1BBDFACA3A... 84000026F87CCA0000" # elided for example

import os
os.startfile(PROTOCOL + TEST_URL, 'open')   # second parameter not needed

# and
import win32api
win32api.ShellExecute(0, 'open', PROTOCOL + TEST_URL, "", "", 0)


I thought I had already tried the first one, not sure what happened.

Sorry for the noise...

    Cheers
    Jon N






More information about the Python-list mailing list