Determine Inspector for New vs Existing MailItem?

B

Brian McCullough

Hello,

I have a custom button that I want displayed on the Inspector for a MailItem
only.

I only want the button displayed for existing mail messages, not new mail
messages. How do I determine the difference in the NewInspector event?

TIA
 
B

Brian McCullough

I tried checking the EntryID property, and that gave me close to what I was
looking for, but not exactly. If you are creating a new item, the
MailItem.EntryID will be an empty string.

But if I Save the new item and then reopen it for editing, I now have an
EntryID and I don't want my button displayed.

I guess I need to determine if I am viewing a received message vs
creating/editing a message. How can I do this?

TIA!
 
E

Eric Legault [MVP - Outlook]

Check for MailItem.Saved or MailItem.Sent = False, or MailItem.Size = 0.
 
K

Ken Slovak - [MVP - Outlook]

A received message will have the various item.ReceivedXX properties set
(ReceivedTime, etc.) as well as various sender properties. As Eric
mentioned, item.Sent will tell you if it was ever sent out.
 
B

Brian McCullough

My current check is based on EntryID and the Sent property for a MailItem (I
also perform check to see if I am using a Word Editor - JUST IN CASE):

If (m_objInspectorReference.IsWordMail = True) And
(m_objInspectorReference.EditorType = olEditorWord) Then
GoTo Leave
End If

If Trim(m_objMailItem.EntryID) <> "" And m_objMailItem.Sent Then
'attempt to add custom button to toolbar...
End If


I like the idea of checking the ReceivedTime property as well. Could there
ever be an instance where the MailItem object's ReceivedTime property is not
set to a valid Date/Time value?

Thanks again!!
 
K

Ken Slovak - [MVP - Outlook]

Well, RecievedTime is probably a bad example, since it might be set if the
item is saved in Drafts. I'd look over the other related properties and the
sent ones using a MAPI viewer such as OutlookSpy to verify which ones to
use.
 

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

Top