[Tutor] Send attachment

Martin Walsh mwalsh at groktech.org
Sun Jul 24 06:28:21 CEST 2005

Jorge Louis De Castro wrote:
> Hello,
> Any ideas how I can use Python and the Windows API to open a PC's mail 
> client and send an attachment?
> The idea is saving some data onto a file and then invoke the email 
> client (OE or Outlook or whatever is the default on the machine) with 
> the recipient's address filled in and the file ready to be sent as an 
> attachment.

Not sure if it would work for your particular situation/environment, but 
you might try to write out a mime encoded text file with an .eml 
extension, and then use...

import os
os.startfile('foo.eml') # I think os.startfile is windows only

> Kinda like when we right-click on a file and select the "send to mail 
> recipient" behavior.
> Been reading docs, trying out samples, and googling this for a few days 
> to no avail.
> Cheers
> jorge

More information about the Tutor mailing list