How to get the MailItem.SentOn property when sending email?


Jenny Tam


I've created a COM add-in for Outlook in VC++. One of my goals is to
create a 'Log and Send' button in the Inspector (for new mail only)
such that when the user clicks it, the add-in will send the email on
behalf of the user. At the same time, the add-in will get various
properties of the email and log them to a SQL database.

I have no problem trapping the Application.ItemSend event. In this
event, I can get most properties I want except for the MailItem.SentOn
property. During the ItemSend event, MailItem.Sent is false and
MailItem.SentOn is undefined.

So how exactly can I get the correct MailItem.SentOn property? I
don't think I can rely on monitoring 'Sent Items' because the user
might choose not to save copies of messages in Sent Items folder. So
should I check Outbox? What about offline users?

I also want to know whether I can update the corresponding MailItem in
the Sent Items folder. For example, I'd like to add a UserProperty
'Logged' (olYesNo) to the MailItem. I don't want to add it during the
ItemSend event because I don't want my recipient to see this
UserProperty. Is this even possible?

Any help is appreciated!

Jenny Tam

Hi there,

I really need help with this. Can somebody out there help?
I'd like to know if this is even possible!

Thank you very much,

Sue Mosher [MVP]

You would need to get the value of that property *after* the item has been sent, i.e. after it has left the Outbox and moved to the Sent Items folder or whatever folder was designated as its final target. And, yes, you're correct that the user could choose not to save it in Sent Items at all. Another option, therefore, would be to use the current system time in your Application.ItemSend code and hope that the user does not have time to delete the item from the Outbox.

Jenny Tam

Thanks for the reply!

So does it mean that it is impossible to get the exact SentOn
property? I thought about your proposed solution, but I am not sure
if this will work for users who are offline ...

I guess I also know the answer to my other question ... that I cannot
add any user property to a sent item.


Jenny Tam

Someone told me that using the PR_LAST_MODIFICATION_TIME in Extended
MAPI might work when the message is about to be sent. Can anybody

In Outlook, MailItem.SentOn, MailItem.LastModificationTime and
MailItem.CreationTime properties are all undefined in
Application.ItemSend(). When I called MailItem.Save() in ItemSend(),
I did get the last two properties. Unfortunately, when I checked the
MailItem later in the Sent Items, both CreationTime and
LastModificationTime are slightly different from the ones I got from
ItemSend(). :(


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question