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

eryk sun eryksun at gmail.com
Tue Jan 12 12:37:09 EST 2016


On Tue, Jan 12, 2016 at 11:10 AM, Chris Angelico <rosuav at gmail.com> 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.

start is a shell command. It also has a quirk that the first quoted
argument is the window title. Here's the correct call:

    subprocess.check_call('start "title" "%s"' % url, shell=True)

That said, since no arguments are being passed the simpler and more
secure way to call ShellExecute in this case is os.startfile(url).



More information about the Python-list mailing list