Fun with Outlook and MAPI

Discussion in 'Python' started by Chris, Dec 10, 2004.

  1. Chris

    Chris Guest

    I'm trying to send an e-mail through outlook. So far I've gotten it to
    work with the mail script at
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/149461 My only
    problem is that when I call Resolve() and Send(), I get confirmation
    dialogs. I will be sending out quite a few e-mails at a time, and would
    rather not have the user have to click yes for every single one. Does
    anyone know a workaround? I know about smtplib, but I would prefer to
    simply make what I have work. Thanks.

    Chris
    Chris, Dec 10, 2004
    #1
    1. Advertising

  2. Chris

    Will McGugan Guest

    Chris wrote:
    > I'm trying to send an e-mail through outlook. So far I've gotten it to
    > work with the mail script at
    > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/149461 My only
    > problem is that when I call Resolve() and Send(), I get confirmation
    > dialogs. I will be sending out quite a few e-mails at a time, and would
    > rather not have the user have to click yes for every single one. Does
    > anyone know a workaround? I know about smtplib, but I would prefer to
    > simply make what I have work. Thanks.


    Alas, I dont think that there is much you can do to prevent the
    confirmation dialogs with Outlook's MAPI dll. MS added them in a service
    pack as an anti-virus measure, so no work-around. Not all clients show
    these anoying dialogs though. Thunderbird definately doesn't.


    Regards,

    Will McGugan
    Will McGugan, Dec 10, 2004
    #2
    1. Advertising

  3. Chris

    David Fraser Guest

    Will McGugan wrote:
    > Chris wrote:
    >
    >> I'm trying to send an e-mail through outlook. So far I've gotten it
    >> to work with the mail script at
    >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/149461 My
    >> only problem is that when I call Resolve() and Send(), I get
    >> confirmation dialogs. I will be sending out quite a few e-mails at a
    >> time, and would rather not have the user have to click yes for every
    >> single one. Does anyone know a workaround? I know about smtplib, but
    >> I would prefer to simply make what I have work. Thanks.

    >
    >
    > Alas, I dont think that there is much you can do to prevent the
    > confirmation dialogs with Outlook's MAPI dll. MS added them in a service
    > pack as an anti-virus measure, so no work-around. Not all clients show
    > these anoying dialogs though. Thunderbird definately doesn't.
    >
    >


    There is actually a workaround. You're using Simple MAPI which has a
    nice easy interface. The confirmation dialogs are only for Simple MAPI.
    Using Extended MAPI can work around the problem but its a lot more tricky.
    See the initial discussion here:
    http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646

    This code has now been included in pywin32 somehow but I can't remember
    where and its late. Should also be a cookbook entry. Maybe Google can
    help :)

    David
    David Fraser, Dec 10, 2004
    #3
  4. Chris

    Will McGugan Guest

    David Fraser wrote:
    >>
    >> Alas, I dont think that there is much you can do to prevent the
    >> confirmation dialogs with Outlook's MAPI dll. MS added them in a
    >> service pack as an anti-virus measure, so no work-around. Not all
    >> clients show these anoying dialogs though. Thunderbird definately
    >> doesn't.
    >>
    >>

    >
    > There is actually a workaround. You're using Simple MAPI which has a


    I stand corrected.

    Will McGugan
    Will McGugan, Dec 10, 2004
    #4
  5. Chris

    Chris Guest

    Will McGugan wrote:
    >> I'm trying to send an e-mail through outlook. So far I've gotten it
    >> to work with the mail script at
    >> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/149461 My
    >> only problem is that when I call Resolve() and Send(), I get
    >> confirmation dialogs. I will be sending out quite a few e-mails at a
    >> time, and would rather not have the user have to click yes for every
    >> single one. Does anyone know a workaround? I know about smtplib, but
    >> I would prefer to simply make what I have work. Thanks.

    > Alas, I dont think that there is much you can do to prevent the
    > confirmation dialogs with Outlook's MAPI dll. MS added them in a service
    > pack as an anti-virus measure, so no work-around. Not all clients show
    > these anoying dialogs though. Thunderbird definately doesn't.


    Unfortunately, I don't have the option of installing Thunderbird.

    Chris
    Chris, Dec 10, 2004
    #5
  6. Chris

    Chris Guest

    >> Alas, I dont think that there is much you can do to prevent the
    >> confirmation dialogs with Outlook's MAPI dll. MS added them in a
    >> service pack as an anti-virus measure, so no work-around. Not all
    >> clients show these anoying dialogs though. Thunderbird definately
    >> doesn't.

    > There is actually a workaround. You're using Simple MAPI which has a
    > nice easy interface. The confirmation dialogs are only for Simple MAPI.
    > Using Extended MAPI can work around the problem but its a lot more tricky.
    > See the initial discussion here:
    > http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646
    >
    > This code has now been included in pywin32 somehow but I can't remember
    > where and its late. Should also be a cookbook entry. Maybe Google can
    > help :)


    Cool. I'll take a look an' see if I can get it to work. MAPI has
    turned out to be a major PITA. Especially when trying to learn it and
    Python at the same time. :)

    Chris
    Chris, Dec 10, 2004
    #6
  7. Chris

    Larry Bates Guest

    At the risk of beating a dead horse, but you really should consider
    using SMTP instead if you are really going to be sending a lot
    of messages. I think you will find it more reliable and much faster.
    It also eliminates the need for ANY email client to be on the machine
    that is sending the messages.

    http://motion.technolust.cx/related/send_jpg.py

    Here is a link to a class that wraps everything up very nicely. You
    should be able to be sending SMTP emails with it in 10-15 minutes.
    It supports binary attachments as well.

    FYI,
    Larry Bates

    Chris wrote:
    > I'm trying to send an e-mail through outlook. So far I've gotten it to
    > work with the mail script at
    > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/149461 My only
    > problem is that when I call Resolve() and Send(), I get confirmation
    > dialogs. I will be sending out quite a few e-mails at a time, and would
    > rather not have the user have to click yes for every single one. Does
    > anyone know a workaround? I know about smtplib, but I would prefer to
    > simply make what I have work. Thanks.
    >
    > Chris
    Larry Bates, Dec 11, 2004
    #7
  8. Chris

    Roger Binns Guest

    "Chris" <> wrote in message news:...
    > My only problem is that when I call Resolve() and Send(), I get confirmation dialogs. I will be sending out quite a few e-mails
    > at a time, and would rather not have the user have to click yes for every single one.


    Here is an simple workaround:

    http://www.contextmagic.com/express-clickyes/

    If you have win32all installed, you can even use the programming API
    they present to turn on and off the clickyes functionality.

    Roger
    Roger Binns, Dec 11, 2004
    #8
  9. Chris

    Roger Binns Guest

    "Larry Bates" <> wrote in message news:...
    > At the risk of beating a dead horse, but you really should consider
    > using SMTP instead if you are really going to be sending a lot
    > of messages.


    The problem is that doesn't work in more complicated configurations
    such as when authentication and/or SSL have to happen, not to mention
    the issue of configuring servers and ports, that users have already
    configured in their mail clients. Additionally when you use MAPI,
    messages that you send also end up in your sent items folder. (I
    also have not had any issue sending lots of messages using MAPI).

    Ultimately the utility of vanilla of pure SMTP will depend on
    customer requirements and how simple the configuration is.

    Roger
    Roger Binns, Dec 11, 2004
    #9
  10. Chris

    Steve Holden Guest

    Chris wrote:

    >>> Alas, I dont think that there is much you can do to prevent the
    >>> confirmation dialogs with Outlook's MAPI dll. MS added them in a
    >>> service pack as an anti-virus measure, so no work-around. Not all
    >>> clients show these anoying dialogs though. Thunderbird definately
    >>> doesn't.

    >>
    >> There is actually a workaround. You're using Simple MAPI which has a
    >> nice easy interface. The confirmation dialogs are only for Simple
    >> MAPI. Using Extended MAPI can work around the problem but its a lot
    >> more tricky.
    >> See the initial discussion here:
    >> http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646
    >>
    >> This code has now been included in pywin32 somehow but I can't
    >> remember where and its late. Should also be a cookbook entry. Maybe
    >> Google can help :)

    >
    >
    > Cool. I'll take a look an' see if I can get it to work. MAPI has
    > turned out to be a major PITA. Especially when trying to learn it and
    > Python at the same time. :)
    >
    > Chris


    There's recently been some discussion of this topic on the python-win32
    list, most lately to accommodate moving sent messages to the Sent
    folder. I've personally sent several hundred messages using the
    techniques outlined there.

    http://mail.python.org/pipermail/python-win32/2004-August/002239.html is
    a good starting point.

    regards
    Steve
    --
    http://www.holdenweb.com
    http://pydish.holdenweb.com
    Holden Web LLC +1 800 494 3119
    Steve Holden, Dec 12, 2004
    #10
  11. Chris

    Chris Guest

    >>At the risk of beating a dead horse, but you really should consider
    >>using SMTP instead if you are really going to be sending a lot
    >>of messages.

    > The problem is that doesn't work in more complicated configurations
    > such as when authentication and/or SSL have to happen, not to mention
    > the issue of configuring servers and ports, that users have already
    > configured in their mail clients. Additionally when you use MAPI,
    > messages that you send also end up in your sent items folder. (I
    > also have not had any issue sending lots of messages using MAPI).
    >
    > Ultimately the utility of vanilla of pure SMTP will depend on
    > customer requirements and how simple the configuration is.


    That pretty much sums it up. Also, since everything is done over IMAP
    with Outlook, I don't really have access to an SMTP server.

    Chris
    Chris, Dec 13, 2004
    #11
  12. Chris

    Chris Guest

    > There is actually a workaround. You're using Simple MAPI which has a
    > nice easy interface. The confirmation dialogs are only for Simple MAPI.
    > Using Extended MAPI can work around the problem but its a lot more tricky.
    > See the initial discussion here:
    > http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646
    >
    > This code has now been included in pywin32 somehow but I can't remember
    > where and its late. Should also be a cookbook entry. Maybe Google can
    > help :)


    Okay, here's the results. The good news is that the code sent the mail
    without any popup's. The bad news is that the sent e-mail stays in the
    outbox instead of the sent folder. Any suggestions?

    Chris
    Chris, Dec 13, 2004
    #12
  13. Chris

    Steve Holden Guest

    Chris wrote:

    >> There is actually a workaround. You're using Simple MAPI which has a
    >> nice easy interface. The confirmation dialogs are only for Simple
    >> MAPI. Using Extended MAPI can work around the problem but its a lot
    >> more tricky.
    >> See the initial discussion here:
    >> http://aspn.activestate.com/ASPN/Mail/Message/Python-win32/2160646
    >>
    >> This code has now been included in pywin32 somehow but I can't
    >> remember where and its late. Should also be a cookbook entry. Maybe
    >> Google can help :)

    >
    >
    > Okay, here's the results. The good news is that the code sent the mail
    > without any popup's. The bad news is that the sent e-mail stays in the
    > outbox instead of the sent folder. Any suggestions?
    >
    > Chris


    Well, only the same one I've already made, which is to look on the
    win32all mailing list archives. Since this appears to be beyond you,
    here's a note by Chad Stryker commenting on an original work by David
    Fraser.

    It may give you the clues you need, otherwise Google for the whole
    thread(s).

    """Thank you for figuring this extended MAPI interface all out. I
    discovered a couple of problems with the code (on my system at least).
    First, the message in my outbox was marked as read. Second, the message
    would remain in the outbox after it was sent. After several hours of
    work, I added three lines to the function that mark the message as
    unread and cause the message to be deleted from the outbox after it is sent.

    First, I added a constant that I found in the MAPI header file MAPIDefS.h.

    CLEAR_READ_FLAG = 4

    Next I added two lines just before “outboxfolder.SaveChanges(0)”.

    message.SetReadFlag(CLEAR_READ_FLAG)
    message.SetProps([(mapitags.PR_DELETE_AFTER_SUBMIT,1)])

    With these changes, the behavior in the outbox is consistent with
    sending messages directly from Outlook.
    """

    regards
    Steve
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
    Steve Holden, Dec 13, 2004
    #13
  14. Chris

    Chris Guest

    >> Okay, here's the results. The good news is that the code sent the
    >> mail without any popup's. The bad news is that the sent e-mail stays
    >> in the outbox instead of the sent folder. Any suggestions?

    > Well, only the same one I've already made, which is to look on the
    > win32all mailing list archives. Since this appears to be beyond you,
    > here's a note by Chad Stryker commenting on an original work by David
    > Fraser.
    >
    > It may give you the clues you need, otherwise Google for the whole
    > thread(s).
    >
    > """Thank you for figuring this extended MAPI interface all out. I
    > discovered a couple of problems with the code (on my system at least).
    > First, the message in my outbox was marked as read. Second, the message
    > would remain in the outbox after it was sent. After several hours of
    > work, I added three lines to the function that mark the message as
    > unread and cause the message to be deleted from the outbox after it is
    > sent.
    >
    > First, I added a constant that I found in the MAPI header file MAPIDefS.h.
    >
    > CLEAR_READ_FLAG = 4
    >
    > Next I added two lines just before “outboxfolder.SaveChanges(0)”.
    >
    > message.SetReadFlag(CLEAR_READ_FLAG)
    > message.SetProps([(mapitags.PR_DELETE_AFTER_SUBMIT,1)])
    >
    > With these changes, the behavior in the outbox is consistent with
    > sending messages directly from Outlook.
    > """
    >
    > regards
    > Steve


    Actually, I had already found that message. It still doesn't do what
    I'm looking for(namely moving sent messages to the Sent folder).

    Chris
    Chris, Dec 13, 2004
    #14
  15. Chris

    Steve Holden Guest

    Chris wrote:

    >>> Okay, here's the results. The good news is that the code sent the
    >>> mail without any popup's. The bad news is that the sent e-mail stays
    >>> in the outbox instead of the sent folder. Any suggestions?

    >>
    >> Well, only the same one I've already made, which is to look on the
    >> win32all mailing list archives. Since this appears to be beyond you,
    >> here's a note by Chad Stryker commenting on an original work by David
    >> Fraser.
    >>
    >> It may give you the clues you need, otherwise Google for the whole
    >> thread(s).
    >>
    >> """Thank you for figuring this extended MAPI interface all out. I
    >> discovered a couple of problems with the code (on my system at least).
    >> First, the message in my outbox was marked as read. Second, the
    >> message would remain in the outbox after it was sent. After several
    >> hours of work, I added three lines to the function that mark the
    >> message as unread and cause the message to be deleted from the outbox
    >> after it is sent.
    >>
    >> First, I added a constant that I found in the MAPI header file
    >> MAPIDefS.h.
    >>
    >> CLEAR_READ_FLAG = 4
    >>
    >> Next I added two lines just before “outboxfolder.SaveChanges(0)”.
    >>
    >> message.SetReadFlag(CLEAR_READ_FLAG)
    >> message.SetProps([(mapitags.PR_DELETE_AFTER_SUBMIT,1)])
    >>
    >> With these changes, the behavior in the outbox is consistent with
    >> sending messages directly from Outlook.
    >> """
    >>
    >> regards
    >> Steve

    >
    >
    > Actually, I had already found that message. It still doesn't do what
    > I'm looking for(namely moving sent messages to the Sent folder).
    >
    > Chris
    >
    >

    Well, in that case please excuse my crotchetiness. It's probably the
    time of year.

    bah-humbug-ly y'rs - steve
    --
    Steve Holden http://www.holdenweb.com/
    Python Web Programming http://pydish.holdenweb.com/
    Holden Web LLC +1 703 861 4237 +1 800 494 3119
    Steve Holden, Dec 13, 2004
    #15
    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. Elad
    Replies:
    0
    Views:
    749
  2. Mark Hahn
    Replies:
    1
    Views:
    947
    Syver Enstad
    Sep 12, 2003
  3. V.C.Sekhar

    Outlook-MAPI

    V.C.Sekhar, May 9, 2005, in forum: Python
    Replies:
    1
    Views:
    4,318
  4. Replies:
    1
    Views:
    1,087
    Lenard Lindstrom
    Apr 1, 2007
  5. Jeff Miller

    Win32Ole, MAPI, and Outlook

    Jeff Miller, Mar 20, 2008, in forum: Ruby
    Replies:
    3
    Views:
    202
    Brian Scott
    Mar 25, 2008
Loading...

Share This Page