Open msg File to get Attachment details

  • Thread starter Thread starter chris
  • Start date Start date
C

chris

Hi,

I am have trouble opening an msg file that has attachments using CDO

My attachments are not loading correctly in the object model and
instead I get attachment added to the text body which is just a garbled
mess.

What I am trying to do is use CDO to open the msg file so I can look at
the number of attachments it has, but as the attachment is not loaded
into the attachments collection the count is not available to me. I am
using the following code to load the file:

Function LoadMessageFromFile(Path As String) As Message
Dim Stm As New Stream
Stm.Open
Stm.LoadFromFile Path
Dim iMsg As New CDO.Message
Dim iDsrc As IDataSource
Set iDsrc = iMsg
iDsrc.OpenObject Stm, "_Stream"
Set LoadMessageFromFile = iMsg
End Function

If anyone can help me I would appreciate it.

TIA

Chris
 
If your main concern is to get at the attachments, you can use the Outlook object model's Namespace.CreateItemFromTemplate method to create a new item that's a copy of the .msg item.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Thanks Sue

I am currently using the outlook object model to load these files and
handle the messages, but I need to find an alternative method to check
the attachment details because the outlook object model does not seem
to work all of the time - it does most of the time but occasionally
says it has no attachments when it should - and I would like to double
check using a different method, hence using CDO to load the msg file
and see if I can extract the data that way.

any ideas?
 
My only idea is that maybe there's something interesting about the attachments in the items that appear to have none -- like maybe they're blocked files.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Do you now if it is actually possible to load the msg file into the CDO
object and retrieve the attachments??

Chris
 
No, I've never tried it. I've always used either Namespace.CreateItemFromTemplate or Redemption.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top