Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Interop / January 2006

Tip: Looking for answers? Try searching our database.

Getting an EmailItem object from EntryID question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Michael H - 11 Jan 2006 00:48 GMT
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);
.
.
.
.
Michael H - 11 Jan 2006 01:05 GMT
For all those who may be picky, by EmailItem I meant MailItem :)...
This is called being very tired while typing.

Michael
Ken Slovak - [MVP - Outlook] - 11 Jan 2006 15:10 GMT
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.

Signature

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

> Hi all,
>
[quoted text clipped - 40 lines]
> .
> .
Michael H - 11 Jan 2006 18:38 GMT
-->  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
Ken Slovak - [MVP - Outlook] - 11 Jan 2006 20:29 GMT
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

Signature

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

> -->  OlDefaultFolders.olFolderInbox.StoreID
> -->
[quoted text clipped - 22 lines]
>
> Michael
Michael H - 12 Jan 2006 01:06 GMT
-->  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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.