Creating an MS Outlook Message

I cannot find out for the life of me, how to open Outlook.exe and create a message through pyrevit.

The python script I have runs just fine from Visual Studio, but when I push it through pyrevit, I get the following error:

“Import Error: no module named win32com.client”

Is there something I’m missing? Does IronPython require a specific library (other than win32com.client) to call Microsoft commands?

This is an example from the python script I wrote:

“”“Open an Outlook Message with the BIM Help Template”""

title = ‘Help\nRequest’
author = ‘Ron Rowcotsky’

import win32com.client as win32
import os

def Emailer(text, subject, recipient):
outlook = win32.Dispatch(‘outlook.application’)
mail = outlook.CreateItem(0)
mail.To = recipient
mail.Subject = subject
mail.HtmlBody = text

MailSubject= “BIM Help”
MailInput=""" body “”"

Emailer(MailInput, MailSubject, MailAdress ) #that open a new outlook mail even outlook closed.

Any advice y’all might have would be greatly appreciated.


first try this to open outlook

import os

you made me open outlook after 4 years of not using it. It felt weird! :grimacing:

and bunch of example, I don’t knwo which one works best with pyrevit
outside pyrevit the smtp module seemed to work

better, about your win32 error

@Jean-Marc, thanks for the quick response.

the os.startfile() module helps me open Outlook, but I still need the list of available commands to compose the message.

Is Outlook the default mail application? Because in that case you can use the mailto:// schema and open a URL. The OS will handle calling the app that is the default mail handler.

See this as well

1 Like

thank you @eirannejad. this is very helpful.

so, rather than forcing outlook to open and compose a message directly from IronPython, I’ve decided a better course of action is to direct people to an MS Form from the pushbutton. The information from the form response is then pushed to through an automated flow (via Power Automate) to create the Outlook message.

Thanks to @eirannejad and @Jean-Marc for helping exhaust all my options.


Instead of creating a whole new thread, I decided to revise this one. I have tried everything mentioned in this thread and they only thing I have managed to accomplish is to open a second instance of Outlook. @ronjr811 I am leaning with you and just handling this through MS Forms and having those requests sent to a MS Teams Team/Channel.