[ANN] PYNOSPAM 0.1 (and some Embedded-Python-Questions)

Gerson Kurz gerson.kurz at t-online.de
Mon Apr 1 04:52:35 EST 2002


On Sat, 30 Mar 2002 23:05:03 +0000, philh at comuno.freeserve.co.uk (phil
hunt) wrote:

>The fact that you've written this demonstrates that Outlook has a 
>way of enabling user-written filters for incoming email. To your 
>knowledge, does Outlook allow filters for outgoing email too?

Yes, but its a really *really* terrible. Don't expect to come out with
a sane mind.

- First of all, the solution works for exactly two mail clients:
Microsoft Outlook, and Microsoft Exchange. Great interoperability, eh?
Whether or not it works for even Microsoft Outlook Express I don't
know. You can see from that that it is not in any way a solution you
can reuse for Eudora, or Netscape, or The Bat. And, worse yet, on the
MSDN site they say MAPI is no longer updated with the advent of .NET,
which is great because to this day there exists no Microsoft Mail
Client using .NET rather than MAPI. 

- Secondly, there are two types of extensions Outlook supports: OLE
Add-Ins, and Exchange Add-Ins. ("Exchange" is basically an old version
of "Outlook"). Neither of which you can write using Pythons COM tools!
Furthermore, OLE Add-Ins are "generic" (the concept of "COM addin" is
present in all Microsoft Office 2000 apps, but "hidden" - check MSDN
if you don't believe it). Plus, AFAIK they only work in Outlook
2000/XP, not in Outlook 98. (Its Microsoft, what did you expect). The
Exchange Extensions are easier to implement (in C++) and work both in
older and newer Outlook clients (until the happy day microsoft decides
no longer to support that API).

- As for your question, there is one interface your extension can
implement (IExchExtMessageEvents), that will give you a chance to
modify the mail before sending. This actually might be a good idea,
because if the end user send their mail using a Microsoft Exchange
Server, you can forget about the SMTP proxy approach. (<irony>And many
people do, because Exchange Server is a socalled "killer app" because
it has shared contacts</irony>). 

- modifying the mail using MAPI is hell. You have a "property storage"
and you can get/set one or more properties for a message from it. Now,
say you want to strip HTML mails (as I do). You find that MAPI defines
a PR_BODY_HTML, (but of course you won't find that in the includes
that come with devstudio6, you need *updated headers* for that:
Download the latest platform SDK). You test with small HTML mails and
it works fine - PR_BODY_HTML is the HTMLized body, and you can change
that. Then you test it and promptly receive some HTML spam that is 17K
in size ("The bitter network administrator"). You query the HTML body
and get MAPI_E_OUT_OF_MEMORY back (get that: on a machine that has 1
GB RAM, and nearly 700MB RAM free, you get out of memory for querying
a 17K message!!!). You look for help in microsoft newsgroups and find
to your utter disbelieve that, if the HTML mail is "too large", you
cannot use the "normal" get/set property method, but must implement a
stream object that reads data from a property stream, and from a
DIFFERENT property none the less called COMPRESSED_RTF. WTF!!!

- To use python from the addin, the C++ written DLL embedds the python
interpreter and runs the spam detection there. 

HTH, Gerson



More information about the Python-list mailing list