win32com: create email message in windows default app?

Discussion in 'Python' started by Mark Hahn, Sep 7, 2003.

  1. Mark Hahn

    Mark Hahn Guest

    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.
     
    Mark Hahn, Sep 7, 2003
    #1
    1. Advertising

  2. 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 = ""
    objEmail.To = ""
    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
    --
    Michel Claveau
    site : http://mclaveau.com
     
    News M Claveau /Hamster-P, Sep 7, 2003
    #2
    1. Advertising

  3. Mark Hahn

    Mark Hahn Guest


    > 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?
     
    Mark Hahn, Sep 7, 2003
    #3
  4. Mark Hahn

    Syver Enstad Guest

    "News M Claveau /Hamster-P" <> writes:

    > 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 = ""
    > objEmail.To = ""
    > 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.


    --

    Vennlig hilsen

    Syver Enstad
     
    Syver Enstad, Sep 7, 2003
    #4
  5. Mark Hahn wrote:


    >> 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?


    What about "opening" the mailto URL you need with Windows' "start"? e.g.
    os.system("start mailto:")
    ? 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:?subject=what ever"')

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


    Alex
     
    Alex Martelli, Sep 8, 2003
    #5
  6. Mark Hahn

    Harald Massa Guest

    >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:?subject=PyPy and
    stacklass&body=please support theses projects")
     
    Harald Massa, Sep 8, 2003
    #6
  7. Mark Hahn

    Graham Breed Guest

    Alex Martelli wrote:

    > Oh btw,
    >
    > os.system('start "mailto:?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
     
    Graham Breed, Sep 8, 2003
    #7
  8. On Mon, 8 Sep 2003 13:51:28 +0200, Harald Massa <> wrote:

    >>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:?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
     
    Bengt Richter, Sep 8, 2003
    #8
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chuck Amadi
    Replies:
    2
    Views:
    422
    chuck amadi
    Jun 6, 2004
  2. David Stockwell
    Replies:
    1
    Views:
    657
    David Bolen
    Jun 17, 2004
  3. Rogério Brito
    Replies:
    1
    Views:
    707
    Sean DiZazzo
    Sep 9, 2009
  4. Chris Rebert
    Replies:
    0
    Views:
    176
    Chris Rebert
    Dec 28, 2012
  5. Terry Reedy
    Replies:
    0
    Views:
    167
    Terry Reedy
    Dec 29, 2012
Loading...

Share This Page