6

I am trying to open Outlook with Python and I got this...

import win32com.client
ol = win32com.client.Dispatch("outlook.Application")

It opens Outlook but my probles is it opens it in the notification area of Windows (where the clock is) and it doesn't open it up on the screen. I tried a ...

OL.visible= True

But I get an error that Outlook application can't be set to visible. So my question is how can I bring Outlook for, or maximze it to a full screen?

0m3r
  • 12,286
  • 15
  • 35
  • 71
Trying_hard
  • 8,931
  • 29
  • 62
  • 85

3 Answers3

10

Ok I found this to work as simple as it was....

import os
os.startfile("outlook")

It makes it into a large window and mot a minimized one.

Trying_hard
  • 8,931
  • 29
  • 62
  • 85
0

You could also check if Outlook is running using psutil

import psutil

def is_outlook_running():
    for p in psutil.process_iter(attrs=['pid', 'name']):
        if "OUTLOOK.EXE" in p.info['name']:
            print("Yes", p.info['name'], "is running")
            break
    else:
        print("No, Outlook is not running")
        os.startfile("outlook")
        print("Outlook is starting now...")
0m3r
  • 12,286
  • 15
  • 35
  • 71
0

Have you seen this SO question? The solution there was to start up Outlook from a shell command and then attach to the running process. It seems dirty, but I've done the same with other programs out of desperation. I would expect MS Office to play nicer with COM.

I wonder if you could do something similar to the MS example here.

Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNameSpace("MAPI")
Set myFolder= _
    myNameSpace.GetDefaultFolder(olFolderInbox)
myFolder.Display

I don't have Outlook installed so I can't test anything.

Community
  • 1
  • 1
chip
  • 2,262
  • 2
  • 20
  • 24