Getting an EmailItem object from EntryID question

M

Michael H

Hi all,


I have an EntryID object that I'm getting from Windows Desktop Search.
I've verified that I'm using EntryID values that exist in Outlook (I
cycled thru each EmailItem in Outlook and printed out each
EmailItem.EntryID to compare what the Interop sees and what WDS spits
out). I don't have experience grabbing individual EmailItem objects
yet so I'm suspicious that I'm skipping a step or just doing something
wrong. I read that I don't need to specify the exact Outlook folder if
I have the EmailItem.EntryID value though I don't know if it was
written by a crazy person or a basic fact. Anyway, I'll paste a code
snipplet below and maybe somebody wiser than I with Outlook
programming can point out the errors. The COM exception thrown seems
to indicate that it doesn't like the input to
NameSpace.GetItemFromID(....) . The EntryID does exist, maybe it's the
StoreID I'm specifying?


Thanks a lot...



using Microsoft.Office.Interop.Outlook;
..
..
..
private ApplicationClass olApplication;
private NameSpace olNameSpace;
..
..
..
..
..
..
..
if (this.olApplication == null)
{
this.olApplication = new ApplicationClass();
this.olNameSpace = this.olApplication.GetNamespace("MAPI");
}

MailItem item = (MailItem) this.olNameSpace.GetItemFromID(strEntryID,
OlDefaultFolders.olFolderInbox);
..
..
..
..
 
M

Michael H

For all those who may be picky, by EmailItem I meant MailItem :)...
This is called being very tired while typing.


Michael
 
K

Ken Slovak - [MVP - Outlook]

OlDefaultFolders.olFolderInbox.StoreID

What you are passing is the actual folder object, not the StoreID. StoreID
is used optionally and is needed only when more than 1 store has been opened
in the Outlook session. Even then it's optional. Using only EntryID usually
works, but doing Outlook development you get used to working with both belt
and suspenders so I always use both EntryID and StoreID myself.
 
M

Michael H

On Wed, 11 Jan 2006 10:10:57 -0500, "Ken Slovak - [MVP - Outlook]"

--> OlDefaultFolders.olFolderInbox.StoreID
-->
--> What you are passing is the actual folder object, not the
StoreID. StoreID
--> is used optionally and is needed only when more than 1 store has
been opened
--> in the Outlook session. Even then it's optional. Using only
EntryID usually
--> works, but doing Outlook development you get used to working with
both belt
--> and suspenders so I always use both EntryID and StoreID myself.
-->
--> --
--> Ken Slovak
--> [MVP - Outlook]
--> http://www.slovaktech.com
--> Author: Absolute Beginner's Guide to Microsoft Office Outlook
2003
--> Reminder Manager, Extended Reminders, Attachment Options
--> http://www.slovaktech.com/products.htm


Thanks For the reply Ken. I'll look at trying this w/o the 2nd
parameter. I don't have a StoreID value available to me that I know of
anyway :(...


Michael
 
K

Ken Slovak - [MVP - Outlook]

If you have a folder reference you have a StoreID reference. StoreID is a
property of a folder. Look in the Object Browser. In fact, if you have an
item that has been saved in the store you also have a StoreID property:
Item.Parent.StoreID
 
M

Michael H

On Wed, 11 Jan 2006 15:29:16 -0500, "Ken Slovak - [MVP - Outlook]"

--> If you have a folder reference you have a StoreID reference.
StoreID is a
--> property of a folder. Look in the Object Browser. In fact, if you
have an
--> item that has been saved in the store you also have a StoreID
property:
--> Item.Parent.StoreID
-->
--> --
--> Ken Slovak
--> [MVP - Outlook]
--> http://www.slovaktech.com
--> Author: Absolute Beginner's Guide to Microsoft Office Outlook
2003
--> Reminder Manager, Extended Reminders, Attachment Options
--> http://www.slovaktech.com/products.htm


Ken,

I managed to get this to work doing this...


olApplication = new ApplicationClass();
olNameSpace = this.olApplication.GetNamespace("MAPI");


MailItem item = (MailItem) this.olNameSpace.GetItemFromID(strEntryID,
null);

string retValue = item.Body;



Of course, that Outlook warning window pops up. I've switched to
trying Dmitry Streblechenko's Redemption.DLL but haven't figured out
the exact way to get the MailItem from a known MailItem.EntryID value.
Perhaps, I'll post a question about that into another thread.


Michael
 

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