MailItem or MailItemClass ?

M

MatrimCauthon

Hello,

Im iterating through selected (hopefully) mail items:

For Each objMsg In objSelection
'check if selected object is mail item
If TypeName(objMsg) = "MailItem" Then

Now my problem:
As long as Im working on the local Personal Folder everything work
just fine but as soon as Im going to another folder on an email serve
to get a new mail the selection delivers MailItemClass as TypeName.
It doesn't change when Im going to the local Personal Folder bac
again.
When I restart Outlook then I can access the mails in the Persona
Folder again.

So now my question:
Why is there sometimes MailItem and sometimes MailItemClass as th
TypeName ?
Is there a way to cast them into each other?
Any other thoughts?


Kinda regards,

Mat.

Edit: I tested again and some message (at the server) are stil
MailItems but only a few =( the new ones and the personal folders ar
MailItemClass. I hope there is a simple solution to this out ther
 
K

Ken Slovak - [MVP - Outlook]

Try using a test for objMsg.Class = olMail instead of using TypeName.
 
M

MatrimCauthon

The Problem was olMail isn't a known constant in Visual Basic .NET.

I think maybe there is a way to load the constant though but I figure
I can use the values instead.

(For the time being I check for both MailItem and MailItemClass and le
them both pass.)
So what I want to know whether is there a difference between these o
not.

Thank you
 

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