Fun with Outlook and MAPI

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Chris

    Fun with Outlook and MAPI

    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/Coo.../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
  • Will McGugan

    #2
    Re: Fun with Outlook and MAPI

    Chris wrote:[color=blue]
    > 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/Coo.../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.[/color]

    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

    Comment

    • David Fraser

      #3
      Re: Fun with Outlook and MAPI

      Will McGugan wrote:[color=blue]
      > Chris wrote:
      >[color=green]
      >> 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/Coo.../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.[/color]
      >
      >
      > 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.
      >
      >[/color]

      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:


      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

      Comment

      • Will McGugan

        #4
        Re: Fun with Outlook and MAPI

        David Fraser wrote:[color=blue][color=green]
        >>
        >> 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.
        >>
        >>[/color]
        >
        > There is actually a workaround. You're using Simple MAPI which has a[/color]

        I stand corrected.

        Will McGugan

        Comment

        • Chris

          #5
          Re: Fun with Outlook and MAPI

          Will McGugan wrote:[color=blue][color=green]
          >> 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/Coo.../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.[/color]
          > 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.[/color]

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

          Chris

          Comment

          • Chris

            #6
            Re: Fun with Outlook and MAPI

            >> Alas, I dont think that there is much you can do to prevent the[color=blue][color=green]
            >> 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.[/color]
            > 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/Mai...-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 :-)[/color]

            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

            Comment

            • Larry Bates

              #7
              Re: Fun with Outlook and MAPI

              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.



              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:[color=blue]
              > 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/Coo.../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[/color]

              Comment

              • Roger Binns

                #8
                Re: Fun with Outlook and MAPI


                "Larry Bates" <lbates@syscono nline.com> wrote in message news:lvKdndOR57 3zlibcRVn-jA@comcast.com. ..[color=blue]
                > 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.[/color]

                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


                Comment

                • Roger Binns

                  #9
                  Re: Fun with Outlook and MAPI


                  "Chris" <ch.list@us-hampton.mail.sa ic.com> wrote in message news:mailman.74 82.1102706309.5 135.python-list@python.org ...[color=blue]
                  > 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.[/color]

                  Here is an simple workaround:

                  Express ClickYes is a tiny program that sits in the System Tray and clicks the Yes button on behalf of you, when Outlook's Security Guard opens prompt dialog saying that a program is trying to send an email with Outlook or access its address book.


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

                  Roger


                  Comment

                  • Steve Holden

                    #10
                    Re: Fun with Outlook and MAPI

                    Chris wrote:
                    [color=blue][color=green][color=darkred]
                    >>> 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.[/color]
                    >>
                    >> 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/Mai...-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 :-)[/color]
                    >
                    >
                    > 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[/color]

                    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/pyt...st/002239.html is
                    a good starting point.

                    regards
                    Steve
                    --


                    Holden Web LLC +1 800 494 3119

                    Comment

                    • Chris

                      #11
                      Re: Fun with Outlook and MAPI

                      >>At the risk of beating a dead horse, but you really should consider[color=blue][color=green]
                      >>using SMTP instead if you are really going to be sending a lot
                      >>of messages.[/color]
                      > 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.[/color]

                      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

                      Comment

                      • Chris

                        #12
                        Re: Fun with Outlook and MAPI

                        > There is actually a workaround. You're using Simple MAPI which has a[color=blue]
                        > 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/Mai...-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 :-)[/color]

                        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

                        Comment

                        • Steve Holden

                          #13
                          Re: Fun with Outlook and MAPI

                          Chris wrote:
                          [color=blue][color=green]
                          >> 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/Mai...-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 :-)[/color]
                          >
                          >
                          > 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[/color]

                          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.S aveChanges(0)”.

                          message.SetRead Flag(CLEAR_READ _FLAG)
                          message.SetProp s([(mapitags.PR_DE LETE_AFTER_SUBM IT,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

                          Comment

                          • Chris

                            #14
                            Re: Fun with Outlook and MAPI

                            >> Okay, here's the results. The good news is that the code sent the[color=blue][color=green]
                            >> 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?[/color]
                            > 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.S aveChanges(0)”.
                            >
                            > message.SetRead Flag(CLEAR_READ _FLAG)
                            > message.SetProp s([(mapitags.PR_DE LETE_AFTER_SUBM IT,1)])
                            >
                            > With these changes, the behavior in the outbox is consistent with
                            > sending messages directly from Outlook.
                            > """
                            >
                            > regards
                            > Steve[/color]

                            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

                            Comment

                            • Steve Holden

                              #15
                              Re: Fun with Outlook and MAPI

                              Chris wrote:
                              [color=blue][color=green][color=darkred]
                              >>> 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?[/color]
                              >>
                              >> 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.S aveChanges(0)”.
                              >>
                              >> message.SetRead Flag(CLEAR_READ _FLAG)
                              >> message.SetProp s([(mapitags.PR_DE LETE_AFTER_SUBM IT,1)])
                              >>
                              >> With these changes, the behavior in the outbox is consistent with
                              >> sending messages directly from Outlook.
                              >> """
                              >>
                              >> regards
                              >> Steve[/color]
                              >
                              >
                              > 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
                              >
                              >[/color]
                              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

                              Comment

                              Working...