2

I want to write a little app to scan employee's mailboxes and cleanse them of credit card numbers (people sometimes email them in unfortunately!)

I've already got something that does this in Outlook, but it means setting up shared mailboxes and is a bit of a hassle. It seems that Exchange-side would be the best option.

I'd like to use EWS, but it's search options are a bit limited (even if I want to get a set of potential candidate emails, I think I need 10 different filters to return emails with the numbers 0-9 in their body... and then to confirm/deny using regular expression in code!)

Anyway, if anyone can think of a nice way to do this using EWS, that would be most excellent!

Kram
  • 4,099
  • 4
  • 39
  • 60

2 Answers2

3

Unfortunately, Regex searches are not possible with EWS. You'll need to pull the messages from the server and perform the search on the client.

There is one thing you can do to speed it up: Instead of polling each mailbox over and over again, use the SyncFolderItems (http://www.infinitec.de/post/2009/06/07/Processing-items-in-an-Exchange-folder-using-EWS-Managed-API.aspx).

Use the cookie you get back in subsequent calls. Obviously, you need to store the cookies somewhere, but a simple database table with the two columns FolderId and cookie is sufficient.

This way you'll only process new/changed items since the last call.

Henning Krause
  • 5,302
  • 3
  • 24
  • 37
  • Thanks for the syncfolderitem info - that's really useful... could well make use of that. – Kram Oct 06 '11 at 10:31
0

This tool uses EWS and Luhn validation to scan for credit cards:

http://scriptscience.com/exchange-sanitizer/

I Stand With Russia
  • 6,254
  • 8
  • 39
  • 67