Re: Any thoughts on this exception?

John Cherney <[email protected]> Sat, 30 Dec 2023 03:11:14 +0000
Newsgroups gmane.mail.spam.spambayes.devel
Message-ID <IA0PR11MB7354DDC21E07A550A22AC084BC9CA@IA0PR11MB7354.namprd11.prod.outlook.com>
--===============7684752250254143211==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_IA0PR11MB7354DDC21E07A550A22AC084BC9CAIA0PR11MB7354namp_"

--_000_IA0PR11MB7354DDC21E07A550A22AC084BC9CAIA0PR11MB7354namp_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Ok. I'll take that as good news.

I have been able to reproduce this exception through the IDE debugger by ju=
st 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.GetFolder=
Generator function. I can't seem to generate a valid folder (store_id and e=
ntry_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.BinFrom=
Hex in NormalizeId, but that doesn't seem to work with Python strings, or b=
yte strings. Because NormalizeId isn't generating something useful, the cal=
l to _OpenEntry a few lines later, which calls _GetMessageStore, which call=
s 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 no=
t, 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 tha=
n a 64/32 bit mismatch. It may be that you need to enable MAPI access or so=
mething similar but I'm afraid I've never used newer versions of office. Go=
ogling 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 t=
hat as a starting point. I think I've gotten most, of the 2.x to 3.x conver=
sions. I have the Add-in registered. I have the Add-ins menu showing up. Bu=
t (and there has to be a 'but') I can't seem to get the win32com mapi to re=
ad anything meaningful. I haven't seen anything helpful in my Google search=
es. 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.19=
35 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 GetF=
older
    folder =3D self._OpenEntry(folder_id)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<redacted>\spambayes\Outlook2000\msgstore.py", line 274, in _Ope=
nEntry
    store =3D self._GetMessageStore(store_id)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<redacted>\spambayes\Outlook2000\msgstore.py", line 247, in _Get=
MessageStore
    store =3D 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 OnFold=
erSwitch
    mapi_folder =3D self.manager.message_store.GetFolder(outlook_folder)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\<redacted>\spambayes\Outlook2000\msgstore.py", line 355, in GetF=
older
    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 th=
is 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 d=
idn't see any on pypi.org? Or is that also a wrong direction?) At this poin=
t, 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]<mailto:[email protected]>

https://mail.python.org/mailman/listinfo/spambayes-dev

--_000_IA0PR11MB7354DDC21E07A550A22AC084BC9CAIA0PR11MB7354namp_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@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;}
/* Style Definitions */
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;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"blue" vlink=3D"purple" style=3D"word-wrap:brea=
k-word">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Ok. I&#8217;ll take that as good news. <o:p></o:p></=
p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I have been able to reproduce this exception through=
 the IDE debugger by just running msgstore.py by itself. It appears that th=
e call to MAPIMsgStore constructor (in function test) is returning successf=
ully, and it looks like valid data.
 The exception happens on the next line, in the store.GetFolderGenerator fu=
nction. I can&#8217;t seem to generate a valid folder (store_id and entry_i=
d tuple). The store_id and entry_id are strings. Are they supposed to be en=
coded as something else in Python3 in
 order to work with pywin32 and mapi? Byte strings don&#8217;t seem to work=
. The call originally had mapi.BinFromHex in NormalizeId, but that doesn&#8=
217;t seem to work with Python strings, or byte strings. Because NormalizeI=
d isn&#8217;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=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">I&#8217;m not familiar enough with this Outlook Add =
Ins or the pywin32 library to guess a next step. Could this be a permission=
s issue? I&#8217;d like to think not, since the 32 bit version of Outlook w=
orks with Spambayes, and, with the 64 bit version
 of Outlook, the MAPILogonEx call seems to work. <o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">jwc<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p></o:p></p>
<div>
<div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in =
0in 0in">
<p class=3D"MsoNormal"><b><span style=3D"mso-ligatures:none">From:</span></=
b><span style=3D"mso-ligatures:none"> Mark Hammond &lt;[email protected]=
om.au&gt;
<br>
<b>Sent:</b> Thursday, December 14, 2023 11:29 AM<br>
<b>To:</b> John Cherney &lt;[email protected]&gt;; spambayes-dev@python=
.org<br>
<b>Subject:</b> Re: [spambayes-dev] Any thoughts on this exception?<o:p></o=
:p></span></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</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=3D"mso-ligat=
ures:none"><o:p></o:p></span></p>
<p>Cheers,<o:p></o:p></p>
<p>Mark<o:p></o:p></p>
<div>
<p class=3D"MsoNormal">On 2023-12-13 11:37 p.m., John Cherney wrote:<o:p></=
o:p></p>
</div>
<blockquote style=3D"margin-top:5.0pt;margin-bottom:5.0pt">
<p class=3D"MsoNormal">I&#8217;ve made some progress. I&#8217;ve cloned smo=
ntanaro&#8217;s spambayes repo and used that as a starting point. I think I=
&#8217;ve gotten most, of the 2.x to 3.x conversions. I have the Add-in reg=
istered. I have the Add-ins menu showing up. But (and there
 has to be a &#8216;but&#8217;) I can&#8217;t seem to get the win32com mapi=
 to read anything meaningful. I haven&#8217;t seen anything helpful in my G=
oogle searches. I&#8217;m throwing this out there hoping that someone has s=
een something like this and can get me unstuck.
<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Loaded bayes database from 'C:\&lt;redacted&gt;\default_bay=
es_database.fs'</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Loaded message database from 'C:\&lt;redacted&gt;\default_m=
essage_database.fs'</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Bayes database initialized with 0 spam and 0 good messages<=
/span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">SpamBayes Outlook Addin Version 2.0a1 (Aug 25, 2022) from s=
ource</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">on Windows 10.0.19045 ()</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">using Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct&nbsp; 2 2023=
, 13:03:39) [MSC v.1935 64 bit (AMD64)]</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Log created Wed Dec 13 22:53:24 2023</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">*** SpamBayes is NOT enabled, so will not filter incoming m=
ail. ***</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Creating new SpamBayes toolbar to host our buttons</span><o=
:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Error finding the MAPI folders for a folder switch event</s=
pan><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">ERROR: 'There appears to be a problem with the SpamBayes co=
nfiguration\r\n\r\nPlease select the SpamBayes manager, and run the\r\nConf=
iguration Wizard to reconfigure the filter.'</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Traceback (most recent call last):</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp; File &quot;C:\&lt;redacted&gt;\spambayes\Outlook2000=
\msgstore.py&quot;, line 347, in GetFolder</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp; folder =3D self._OpenEntry(folder_id)</s=
pan><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp; ^^^^^^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp; File &quot;C:\&lt;redacted&gt;\spambayes\Outlook2000=
\msgstore.py&quot;, line 274, in _OpenEntry</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp; store =3D self._GetMessageStore(store_id=
)</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp; File &quot;C:\&lt;redacted&gt;\spambayes\Outlook2000=
\msgstore.py&quot;, line 247, in _GetMessageStore</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp; store =3D self.session.OpenMsgStore(</sp=
an><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp; ^^^^^^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">pywintypes.com_error: (-2147221241, 'OLE error 0x80040107',=
 None, None)</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">During handling of the above exception, another exception o=
ccurred:</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">Traceback (most recent call last):</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp; File &quot;C:\&lt;redacted&gt;\spambayes\Outlook2000=
\addin.py&quot;, line 1178, in OnFolderSwitch</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp; mapi_folder =3D self.manager.message_sto=
re.GetFolder(outlook_folder)</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^=
^^^^^^^^^^^^^^^^^^^^^</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp; File &quot;C:\&lt;redacted&gt;\spambayes\Outlook2000=
\msgstore.py&quot;, line 355, in GetFolder</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">&nbsp;&nbsp;&nbsp; raise MsgStoreExceptionFromCOMException(=
details)</span><o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">msgstore.MsgStoreException: MsgStoreException: Exception 0x=
-7ffbfef9 (MAPI_E_INVALID_ENTRYID): OLE error 0x80040107</span><o:p></o:p><=
/p>
<p class=3D"MsoNormal"><span style=3D"font-size:9.0pt;font-family:&quot;Cou=
rier New&quot;">ERROR: 'There appears to be a problem with the SpamBayes co=
nfiguration\r\n\r\nPlease select the SpamBayes manager, and run the\r\nConf=
iguration Wizard to reconfigure the filter.'</span><o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal">One thing I&#8217;m suspicious of (and I hope I&#821=
7;m wrong) is if the problem is the win32 related modules. I&#8217;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&#8217;t see =
any on pypi.org? Or is that also a wrong direction?) At this point, I don&#=
8217;t know enough about COM or 32bit vs 64bit to know what to try next.
<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;<o:p></o:p></p>
<p class=3D"MsoNormal">Thanks in advance,<o:p></o:p></p>
<p class=3D"MsoNormal">jwc<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"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=3D"mailto:[email protected]">[email protected]</=
a><o:p></o:p></pre>
<pre><a href=3D"https://mail.python.org/mailman/listinfo/spambayes-dev">htt=
ps://mail.python.org/mailman/listinfo/spambayes-dev</a><o:p></o:p></pre>
</blockquote>
</div>
</body>
</html>

--_000_IA0PR11MB7354DDC21E07A550A22AC084BC9CAIA0PR11MB7354namp_--

--===============7684752250254143211==
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

--===============7684752250254143211==--