Re: Any thoughts on this exception?

Marko von Oppen <[email protected]> Tue, 2 Jan 2024 22:26:25 +0100
Newsgroups gmane.mail.spam.spambayes.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--===============7270275464254533491==
Content-Type: multipart/alternative;
 boundary="------------AILLfsOwVvaUeIGZaYxp4t0m"
Content-Language: de-DE, en-US

This is a multi-part message in MIME format.
--------------AILLfsOwVvaUeIGZaYxp4t0m
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Do you have a Outlook object model matching your Outlook version? Maybe 
you could generate one with 'makepy' and check if using this makes any 
difference.


Am 30.12.2023 um 04:11 schrieb John Cherney:
>
> Ok. I’ll take that as good news.
>
> I have been able to reproduce this exception through the IDE debugger 
> by just running msgstore.py by itself. It appears that the call to 
> MAPIMsgStore constructor (in function test) is returning successfully, 
> and it looks like valid data. The exception happens on the next line, 
> in the store.GetFolderGenerator function. I can’t seem to generate a 
> valid folder (store_id and entry_id tuple). The store_id and entry_id 
> are strings. Are they supposed to be encoded as something else in 
> Python3 in order to work with pywin32 and mapi? Byte strings don’t 
> seem to work. The call originally had mapi.BinFromHex in NormalizeId, 
> but that doesn’t seem to work with Python strings, or byte strings. 
> Because NormalizeId isn’t generating something useful, the call to 
> _OpenEntry a few lines later, which calls _GetMessageStore, which 
> calls session.OpenMsgStore, fails.
>
> I’m not familiar enough with this Outlook Add Ins or the pywin32 
> library to guess a next step. Could this be a permissions issue? I’d 
> like to think not, since the 32 bit version of Outlook works with 
> Spambayes, and, with the 64 bit version of Outlook, the MAPILogonEx 
> call seems to work.
>
> jwc
>
> *From:*Mark Hammond <[email protected]>
> *Sent:* Thursday, December 14, 2023 11:29 AM
> *To:* John Cherney <[email protected]>; [email protected]
> *Subject:* Re: [spambayes-dev] Any thoughts on this exception?
>
> That exception looks more like we can't access the message store 
> rather than a 64/32 bit mismatch. It may be that you need to enable 
> MAPI access or something similar but I'm afraid I've never used newer 
> versions of office. Googling for MAPI_E_INVALID_ENTRYID with Office 
> 365 is probably the best path forward.
>
> Cheers,
>
> Mark
>
> On 2023-12-13 11:37 p.m., John Cherney wrote:
>
>     I’ve made some progress. I’ve cloned smontanaro’s spambayes repo
>     and used that as a starting point. I think I’ve gotten most, of
>     the 2.x to 3.x conversions. I have the Add-in registered. I have
>     the Add-ins menu showing up. But (and there has to be a ‘but’) I
>     can’t seem to get the win32com mapi to read anything meaningful. I
>     haven’t seen anything helpful in my Google searches. I’m throwing
>     this out there hoping that someone has seen something like this
>     and can get me unstuck.
>
>     Loaded bayes database from 'C:\<redacted>\default_bayes_database.fs'
>
>     Loaded message database from
>     'C:\<redacted>\default_message_database.fs'
>
>     Bayes database initialized with 0 spam and 0 good messages
>
>     SpamBayes Outlook Addin Version 2.0a1 (Aug 25, 2022) from source
>
>     on Windows 10.0.19045 ()
>
>     using Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39)
>     [MSC v.1935 64 bit (AMD64)]
>
>     Log created Wed Dec 13 22:53:24 2023
>
>     *** SpamBayes is NOT enabled, so will not filter incoming mail. ***
>
>     Creating new SpamBayes toolbar to host our buttons
>
>     Error finding the MAPI folders for a folder switch event
>
>     ERROR: 'There appears to be a problem with the SpamBayes
>     configuration\r\n\r\nPlease select the SpamBayes manager, and run
>     the\r\nConfiguration Wizard to reconfigure the filter.'
>
>     Traceback (most recent call last):
>
>       File "C:\<redacted>\spambayes\Outlook2000\msgstore.py", line
>     347, in GetFolder
>
>         folder = self._OpenEntry(folder_id)
>
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>       File "C:\<redacted>\spambayes\Outlook2000\msgstore.py", line
>     274, in _OpenEntry
>
>         store = self._GetMessageStore(store_id)
>
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>       File "C:\<redacted>\spambayes\Outlook2000\msgstore.py", line
>     247, in _GetMessageStore
>
>         store = self.session.OpenMsgStore(
>
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>     pywintypes.com_error: (-2147221241, 'OLE error 0x80040107', None,
>     None)
>
>     During handling of the above exception, another exception occurred:
>
>     Traceback (most recent call last):
>
>       File "C:\<redacted>\spambayes\Outlook2000\addin.py", line 1178,
>     in OnFolderSwitch
>
>     mapi_folder = self.manager.message_store.GetFolder(outlook_folder)
>
>     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>       File "C:\<redacted>\spambayes\Outlook2000\msgstore.py", line
>     355, in GetFolder
>
>         raise MsgStoreExceptionFromCOMException(details)
>
>     msgstore.MsgStoreException: MsgStoreException: Exception
>     0x-7ffbfef9 (MAPI_E_INVALID_ENTRYID): OLE error 0x80040107
>
>     ERROR: 'There appears to be a problem with the SpamBayes
>     configuration\r\n\r\nPlease select the SpamBayes manager, and run
>     the\r\nConfiguration Wizard to reconfigure the filter.'
>
>     One thing I’m suspicious of (and I hope I’m wrong) is if the
>     problem is the win32 related modules. I’m doing this on a 64bit
>     machine, trying to get this to work with the 64bit install of
>     Outlook (Office 365). Could that be my problem? Should I be
>     looking for win64 related modules? (Do any exist? I didn’t see any
>     on pypi.org? Or is that also a wrong direction?) At this point, I
>     don’t know enough about COM or 32bit vs 64bit to know what to try
>     next.
>
>     Thanks in advance,
>
>     jwc
>
>
>
>     _______________________________________________
>
>     spambayes-dev mailing list
>
>     [email protected]
>
>     https://mail.python.org/mailman/listinfo/spambayes-dev
>
>
> _______________________________________________
> spambayes-dev mailing list
> [email protected]
> https://mail.python.org/mailman/listinfo/spambayes-dev

--------------AILLfsOwVvaUeIGZaYxp4t0m
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Do you have a Outlook object model matching your Outlook version?
      Maybe you could generate one with 'makepy' and check if using this
      makes any difference.<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">Am 30.12.2023 um 04:11 schrieb John
      Cherney:<br>
    </div>
    <blockquote type="cite"
cite="mid:IA0PR11MB7354DDC21E07A550A22AC084BC9CA-py0Qfd72NcxQ3j7nw2tyHJPPoyLQLiKMvxpqHgZTriW3zl9H0oFU5g@public.gmane.org">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator"
        content="Microsoft Word 15 (filtered medium)">
      <style>@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face
	{font-family:Consolas;
	panose-1:2 11 6 9 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-ligatures:standardcontextual;}a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:blue;
	text-decoration:underline;}pre
	{mso-style-priority:99;
	mso-style-link:"HTML Preformatted Char";
	margin:0in;
	font-size:10.0pt;
	font-family:"Courier New";
	mso-ligatures:none;}span.HTMLPreformattedChar
	{mso-style-name:"HTML Preformatted Char";
	mso-style-priority:99;
	mso-style-link:"HTML Preformatted";
	font-family:"Consolas",serif;
	mso-ligatures:standardcontextual;}span.EmailStyle22
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:windowtext;}.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;
	mso-ligatures:none;}div.WordSection1
	{page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal">Ok. I’ll take that as good news. <o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I have been able to reproduce this
          exception through the IDE debugger by just running msgstore.py
          by itself. It appears that the call to MAPIMsgStore
          constructor (in function test) is returning successfully, and
          it looks like valid data. The exception happens on the next
          line, in the store.GetFolderGenerator function. I can’t seem
          to generate a valid folder (store_id and entry_id tuple). The
          store_id and entry_id are strings. Are they supposed to be
          encoded as something else in Python3 in order to work with
          pywin32 and mapi? Byte strings don’t seem to work. The call
          originally had mapi.BinFromHex in NormalizeId, but that
          doesn’t seem to work with Python strings, or byte strings.
          Because NormalizeId isn’t generating something useful, the
          call to _OpenEntry a few lines later, which calls
          _GetMessageStore, which calls session.OpenMsgStore, fails.
          <o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">I’m not familiar enough with this Outlook
          Add Ins or the pywin32 library to guess a next step. Could
          this be a permissions issue? I’d like to think not, since the
          32 bit version of Outlook works with Spambayes, and, with the
          64 bit version of Outlook, the MAPILogonEx call seems to work.
          <o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">jwc<o:p></o:p></p>
        <p class="MsoNormal"><o:p></o:p></p>
        <div>
          <div
style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b><span style="mso-ligatures:none">From:</span></b><span
                style="mso-ligatures:none"> Mark Hammond
                <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a>
                <br>
                <b>Sent:</b> Thursday, December 14, 2023 11:29 AM<br>
                <b>To:</b> John Cherney <a class="moz-txt-link-rfc2396E" href="mailto:[email protected]">&lt;[email protected]&gt;</a>;
                <a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a><br>
                <b>Subject:</b> Re: [spambayes-dev] Any thoughts on this
                exception?<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p>That exception looks more like we can't access the message
          store rather than a 64/32 bit mismatch. It may be that you
          need to enable MAPI access or something similar but I'm afraid
          I've never used newer versions of office. Googling for
          MAPI_E_INVALID_ENTRYID with Office 365 is probably the best
          path forward.<span style="mso-ligatures:none"><o:p></o:p></span></p>
        <p>Cheers,<o:p></o:p></p>
        <p>Mark<o:p></o:p></p>
        <div>
          <p class="MsoNormal">On 2023-12-13 11:37 p.m., John Cherney
            wrote:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">I’ve made some progress. I’ve cloned
            smontanaro’s spambayes repo and used that as a starting
            point. I think I’ve gotten most, of the 2.x to 3.x
            conversions. I have the Add-in registered. I have the
            Add-ins menu showing up. But (and there has to be a ‘but’) I
            can’t seem to get the win32com mapi to read anything
            meaningful. I haven’t seen anything helpful in my Google
            searches. I’m throwing this out there hoping that someone
            has seen something like this and can get me unstuck.
            <o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Loaded bayes
              database from
              'C:\&lt;redacted&gt;\default_bayes_database.fs'</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Loaded
              message database from
              'C:\&lt;redacted&gt;\default_message_database.fs'</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Bayes
              database initialized with 0 spam and 0 good messages</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">SpamBayes
              Outlook Addin Version 2.0a1 (Aug 25, 2022) from source</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">on Windows
              10.0.19045 ()</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">using Python
              3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC
              v.1935 64 bit (AMD64)]</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Log created
              Wed Dec 13 22:53:24 2023</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">***
              SpamBayes is NOT enabled, so will not filter incoming
              mail. ***</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Creating new
              SpamBayes toolbar to host our buttons</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Error
              finding the MAPI folders for a folder switch event</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">ERROR:
              'There appears to be a problem with the SpamBayes
              configuration\r\n\r\nPlease select the SpamBayes manager,
              and run the\r\nConfiguration Wizard to reconfigure the
              filter.'</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Traceback
              (most recent call last):</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">  File
              "C:\&lt;redacted&gt;\spambayes\Outlook2000\msgstore.py",
              line 347, in GetFolder</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">    folder =
              self._OpenEntry(folder_id)</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">            
              ^^^^^^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">  File
              "C:\&lt;redacted&gt;\spambayes\Outlook2000\msgstore.py",
              line 274, in _OpenEntry</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">    store =
              self._GetMessageStore(store_id)</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">           
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">  File
              "C:\&lt;redacted&gt;\spambayes\Outlook2000\msgstore.py",
              line 247, in _GetMessageStore</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">    store =
              self.session.OpenMsgStore(</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">           
              ^^^^^^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">pywintypes.com_error:
              (-2147221241, 'OLE error 0x80040107', None, None)</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">During
              handling of the above exception, another exception
              occurred:</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;"> </span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">Traceback
              (most recent call last):</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">  File
              "C:\&lt;redacted&gt;\spambayes\Outlook2000\addin.py", line
              1178, in OnFolderSwitch</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">   
              mapi_folder =
              self.manager.message_store.GetFolder(outlook_folder)</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">                 
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">  File
              "C:\&lt;redacted&gt;\spambayes\Outlook2000\msgstore.py",
              line 355, in GetFolder</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">    raise
              MsgStoreExceptionFromCOMException(details)</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">msgstore.MsgStoreException:
              MsgStoreException: Exception 0x-7ffbfef9
              (MAPI_E_INVALID_ENTRYID): OLE error 0x80040107</span><o:p></o:p></p>
          <p class="MsoNormal"><span
style="font-size:9.0pt;font-family:&quot;Courier New&quot;">ERROR:
              'There appears to be a problem with the SpamBayes
              configuration\r\n\r\nPlease select the SpamBayes manager,
              and run the\r\nConfiguration Wizard to reconfigure the
              filter.'</span><o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">One thing I’m suspicious of (and I hope
            I’m wrong) is if the problem is the win32 related modules.
            I’m doing this on a 64bit machine, trying to get this to
            work with the 64bit install of Outlook (Office 365). Could
            that be my problem? Should I be looking for win64 related
            modules? (Do any exist? I didn’t see any on pypi.org? Or is
            that also a wrong direction?) At this point, I don’t know
            enough about COM or 32bit vs 64bit to know what to try next.
            <o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Thanks in advance,<o:p></o:p></p>
          <p class="MsoNormal">jwc<o:p></o:p></p>
          <p class="MsoNormal"><span style="mso-ligatures:none"><br>
              <br>
              <o:p></o:p></span></p>
          <pre>_______________________________________________<o:p></o:p></pre>
          <pre>spambayes-dev mailing list<o:p></o:p></pre>
          <pre><a href="mailto:[email protected]"
          moz-do-not-send="true" class="moz-txt-link-freetext">[email protected]</a><o:p></o:p></pre>
          <pre><a
          href="https://mail.python.org/mailman/listinfo/spambayes-dev"
          moz-do-not-send="true" class="moz-txt-link-freetext">https://mail.python.org/mailman/listinfo/spambayes-dev</a><o:p></o:p></pre>
        </blockquote>
      </div>
      <br>
      <fieldset class="moz-mime-attachment-header"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
spambayes-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:[email protected]">[email protected]</a>
<a class="moz-txt-link-freetext" href="https://mail.python.org/mailman/listinfo/spambayes-dev">https://mail.python.org/mailman/listinfo/spambayes-dev</a>
</pre>
    </blockquote>
    <div class="moz-signature"><br>
    </div>
  </body>
</html>

--------------AILLfsOwVvaUeIGZaYxp4t0m--

--===============7270275464254533491==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
spambayes-dev mailing list
[email protected]
https://mail.python.org/mailman/listinfo/spambayes-dev

--===============7270275464254533491==--