Transform DocumentItem Objects as Outlook Item Objects in folder

  • Thread starter Thread starter Wnick
  • Start date Start date
W

Wnick

HI,

I have the next problem:

I use CopyFile Method of Outlook.Application to copy msg file into 'inbox'
outlook folder and put this file as DocumentItem type. Is there is possible
to determine what real type of Items in 'inbox' folder after run CopyFile
Method
for file in which there can be a item of one following type:

* AppointmentItem
* ContactItem
* DistListItem
* DocumentItem
* JournalItem
* MailItem
* MeetingItem
* NoteItem
* PostItem
* RemoteItem
* ReportItem
* TaskItem
* TaskRequestAcceptItem
* TaskRequestDeclineItem
* TaskRequestItem
* TaskRequestUpdateItem

and how to transform DocumentItem to its real type and then run SaveAs
method for this Item.

Nick
 
Create it as an object, then use the Class property to determine what type
it really is. Look at the OlObjectClass enum to see what values and types
you will get back from Class.
 
It is good idea but problem is that I have a file for example C:\h.msg and
I call CopyFile Method of Outlook.Application to put this file into
'inbox'outlook folder then when I tried to access item in this folder like

Dim myItem As Object
Set myItem = myOlApp.ActiveInspector.CurrentItem

and when I read Class property of myItem I am given it as DocumentItem
but if I run Outlook and look at the inbox folder and double click on h.msg
file I see it as MailItem
as I know that DocumentItem object is any document other than a Microsoft
Outlook item but I have put
file which has MailItem in itself

Nick
 
Was the item saved as a MSG file actually a DocumentItem? If so then that's
what it is. Otherwise I'm not sure why it's showing up as a MSG item. I try
not to use MSG items due to the lack of fidelity with the original items in
some of the properties.
 
Yes this file was saved as msg file ( File->Sava As; Save As type: Outlook
Message Format) and then
I tried to copy the file into outlook 'inbox' folder. The method copies the
file but in this case
all items (which was created by CopyFile Method of Outlook.Application in
Outlook 'inbox' folder)
will be as DocumentItem and it is not possible to determine what real type
of Item because I am
always given a class of the item as DocumentItem in spite of the fact that
the item could be
MailItem.

example:

Dim olApp As New Outlook.Application

olApp.CopyFile("C:\h.msg", "Inbox")

Dim myItem As Object

Set myItem = myFolder.Items[1]

and myItem.Class always will be as DocumentItem even it is actually msg
outlook item


I think this is grave disadvantage of Outlook Object Model. Also I would
suggest
there would be some method which determines whether a local file is Msg file
format and real type of item
which the file contains. Also there would be a property of a DocumentItem
which shows whether DocumentItem
is Msg Outlook Item and a method which return real Outlook item which
DocumentItem contains.

To avoid the problem I could open Inspector object for DocumentItem and then
using the inspector object
I would get real Outlook item but this doesn't solve my problem

Nick
 
Well, you're not going to solve limitations of the Outlook object model
here. The Redemption library provides a RDOMail.Import() method that can
import a MSG file into Outlook and it has an optional Type argument that can
be used. You might want to try that. Other than that I'm out of ideas.
 
Back
Top