tags:

views:

392

answers:

2

I'd like to calculate the age of the messages in an Exchange mailbox to make sure they sit there for at least a minute before our program (C++, MAPI) processes them. This way the spam filter we use should have enough time to do its job.

Because the time on the PC where our program runs might be different from the time used by the Exchange server, our program has to read the server time via MAPI.

Is there an elegant solution to it? One way I can think of is to modify some Item and immediately read its PR_LAST_MODIFICATION_TIME, but I'd like to avoid that.

Edit:
Our program is a batch job that runs every 10 minutes and reads the journal mailbox.

A: 

You can use PR_MESSAGE_DELIVERY_TIME.

As per MSDN:

The PR_MESSAGE_DELIVERY_TIME property describes the time the message was stored at the server, rather than the download time when the transport provider copied the message from the server to the local store.

Other than that - when your solution runs on the client anyway - why not use the client time in the first place? Incorrect clock or not, for relative times (e.g. "one minute after ...") this should make no difference.

Tomalak
+1  A: 

I presume you are getting a MAPI event notification when the message arrives in the Exchange mailbox. I would suggest pushing these messages into a queue and waiting n seconds (e.g. 60s) before processing the message. Since the time is relative to the notification event there will be no issue with respect to clock drift between the computers.

On start up of your application you would be forced to do this for existing messages again but I would not imagine that this would pose an issue.

Henk