0

I'm developing an Outlook addin in C# and have a problem distinguishing mails opened from a folder (Inbox, Sent etc) from mails opened from a standalone .msg file.

I've tried inspecting the Parent property, but it shows Inbox for both kinds.

Any ideas out there?

/Sam

Sam
  • 1

1 Answers1

1

Looking through the properties, it looks to me that the .EntryID property is blank if the MailItem is opened from the file system, and has a value if the file is opened from within a folder. This makes sense based on the help entry for it; one caveat is that you'd also expect this property to be blank if the message is a new message (i.e. hasn't been saved in a folder, but doesn't exist in the file system either).

From the help concerning blank values:

Therefore, the EntryID property is not set for an Outlook item until it is saved or sent

You'd want to experiment with it and make sure it definitely behaves correctly before you implemented it :)

Failing all THAT, the next step could be complex; one approach would be to inspect the handles opened by Outlook. Inspecting them (in a non-priveleged context) via Process Explorer shows that there is a handle for each message; the name of the handle matches the message subject, the path is the file's path. One solution to enumerate these is in this answer.

HTH, Geoff

Community
  • 1
  • 1
Geoff
  • 8,551
  • 1
  • 43
  • 50
  • Thanks! EntryID in combination with Sent is what i was after. A bit nervous about how different mail stores behaves though, but that'll show, I suppose. – Sam Sep 13 '10 at 08:41