Script to Remove Attachments in Exchange Mailbox

Tim Golden mail at timgolden.me.uk
Fri Oct 12 04:26:44 EDT 2007


[KDawg44]

>>> I am frustrated with my users who send large files around the office
>>> instead of using the network shares.

[Tim Golden]
>> I have something v. similar, ...
>> It's a while since they were last run to they're probably quite
>> dusty but it sounds like the kind of thing you're after.

Well, here's[1] the first part -- running through folders and replacing
big attachments with links. Now I look, it's designed to be run by
a user on his/her own mailbox rather than by an administrator. Naturally
it's got some stuff which is specific to my setup but nothing, I think,
which isn't easily understood and adapted or removed.

One note is that, as it says in the comments, there doesn't seem to
be a way of identifying large attachments as such, only large messages.
So there may be some corner case where an attachment is stripped out
which is in fact quite small. Obviously you could adapt the
process_attachment function to do something fancier than it is based
on the saved file size etc.

There are no dependencies outside the stdlib except, of course, the
pywin32 package. (Which is, for me, part of the stdlib whenever I
install on Windows). Feel free to email me privately or on-list if
you wish if there's anything which isn't clear etc.

TJG

[1] http://timgolden.me.uk/python/downloads/strip_attachments.py




More information about the Python-list mailing list