MailItem or MailItemClass ?

  • Thread starter Thread starter MatrimCauthon
  • Start date Start date
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
 
Try using a test for objMsg.Class = olMail instead of using TypeName.
 
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
 
Back
Top