win32com: create email message in windows default app?

M

Mark Hahn

Can someone point me in the right direction to tell windows to run the
default email application, create a new message, and let me populate it with
subject, body, and attachments? I've been studying win32com.client and I
think I could use it for a specific application like outlook, but I need it
to work for any app such as Eudora.
 
N

News M Claveau /Hamster-P

Hi !

But what is "windows default email application" ?

In windows, with WSH, you can write :
Dim str,objEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "(e-mail address removed)"
objEmail.To = "(e-mail address removed)"
objEmail.Subject = "Msg-try"
objEmail.Textbody = "Corps (body) du (of) message."
objEmail.Send
Wscript.quit
And run, without pb.
Other way : use MAPI application (essentially outlook-express, or outlook),
but the "default notion" is bad definition (why MAPI more than CDO or more
than Python-library ? )

Windows give sockets and applications use sockets, without priority.
Applications like yours, virus, trojan, anti-virus, python-scripts, etc.

-sorry for my poor english-

@-salutations
 
M

Mark Hahn

But what is "windows default email application" ?

I don't know, except that windows applications such as outlook and outlook
express will ask "Outlook is no longer the default email application, would
you like to make it the default?". So somebody somewhere inside of windows
thinks there is a default.

Also, when you click on a mailto: link in a web browser, only one mail
message comes up from one mail application, so it must be the default email
application. How do I get to that default email application and tell it to
open a message for me?
 
S

Syver Enstad

News M Claveau /Hamster-P said:
Hi !

But what is "windows default email application" ?

That is the application currently chosen as the mail application in
Internet Options / Programs. These settings will be used by any
application that is a Mapi client.

In windows, with WSH, you can write :
Dim str,objEmail
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "(e-mail address removed)"
objEmail.To = "(e-mail address removed)"
objEmail.Subject = "Msg-try"
objEmail.Textbody = "Corps (body) du (of) message."
objEmail.Send
Wscript.quit

You should be equally able to use this with python. Just use
win32com.client instead:

Like this:

import win32com.client
objEmail = win32com.client.Dispatch('CDO.Message')
and so on.

That reason that this works is that CDO uses Mapi behind the scenes.
 
A

Alex Martelli

Mark Hahn wrote:

I don't know, except that windows applications such as outlook and outlook
express will ask "Outlook is no longer the default email application,
would
you like to make it the default?". So somebody somewhere inside of
windows thinks there is a default.

Also, when you click on a mailto: link in a web browser, only one mail
message comes up from one mail application, so it must be the default
email
application. How do I get to that default email application and tell it
to open a message for me?

What about "opening" the mailto URL you need with Windows' "start"? e.g.
os.system("start mailto:[email protected]")
? Or of course you may use more advanced COM Monicker handling for
the "mailto:etc" monicker -- I'm sure the COM parts of win32all and/or
ctypes let you muck with Monickers as needed (even though the internals
of low-level Monicker API's, as I recall from my Windows days, are as
mucky as the overall functionality is neat, still, if the functionality
of "start" isn't sufficient, low-level Monicker API's will no doubt
give you all that it IS feasible to obtain on Windows for this purpose),

Oh btw,

os.system('start "mailto:[email protected]?subject=what ever"')

if you want to pump the subject into the msg as well as the recipient.


Alex
 
H

Harald Massa

run the
default email application, create a new message, and let me populate it
with subject, body, and attachments?

if you do not need attachements...


import webbrwoser

webbrowser.open("mailto:[email protected]?subject=PyPy and
stacklass&body=please support theses projects")
 
G

Graham Breed

Alex said:
Oh btw,

os.system('start "mailto:[email protected]?subject=what ever"')

if you want to pump the subject into the msg as well as the recipient.

If I click that link in Mozilla, I get "whatever" as a single word. I
don't think I ever worked out a way for Outlook and Mozilla to agree
that there's a space in a subject. Either could be the default Windows
mail client.


Graham
 
B

Bengt Richter

if you do not need attachements...


import webbrwoser

webbrowser.open("mailto:[email protected]?subject=PyPy and
stacklass&body=please support theses projects")
That seems to work nicely under NT4 with Python2.3 and Eudora.
And it doesn't send the email (a Good Thing IMO), so it should
be possible to continue in Eudora with more text etc.,
and attach something if desired.

Regards,
Bengt Richter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top