Help!

Open msg File to get Attachment details

 
  

Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA RSS
Next:  macros in Outlook  
Author Message
chris
External


Since: Nov 09, 2005
Posts: 5



PostPosted: Wed Nov 09, 2005 11:25 am    Post subject: Open msg File to get Attachment details
Archived from groups: microsoft>public>outlook>program_vba (more info?)

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
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Thu Nov 10, 2005 8:24 am    Post subject: Re: Open msg File to get Attachment details [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"chris" <chris.DeleteThis@shouson.co.uk> wrote in message news:1131564301.500621.86600@g14g2000cwa.googlegroups.com...
> 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
>
Back to top
chris
External


Since: Nov 09, 2005
Posts: 5



PostPosted: Thu Nov 10, 2005 9:47 am    Post subject: Re: Open msg File to get Attachment details [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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?
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Thu Nov 10, 2005 1:11 pm    Post subject: Re: Open msg File to get Attachment details [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"chris" <chris.DeleteThis@shouson.co.uk> wrote in message news:1131644844.799275.63550@g47g2000cwa.googlegroups.com...
> 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?
>
Back to top
chris
External


Since: Nov 09, 2005
Posts: 5



PostPosted: Thu Nov 10, 2005 3:02 pm    Post subject: Re: Open msg File to get Attachment details [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Do you now if it is actually possible to load the msg file into the CDO
object and retrieve the attachments??

Chris
Back to top
Sue Mosher [MVP-Outlook]
External


Since: Feb 11, 2005
Posts: 21627



PostPosted: Fri Nov 11, 2005 8:43 am    Post subject: Re: Open msg File to get Attachment details [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

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
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx


"chris" <chris RemoveThis @shouson.co.uk> wrote in message news:1131659363.365238.207280@z14g2000cwz.googlegroups.com...
> Do you now if it is actually possible to load the msg file into the CDO
> object and retrieve the attachments??
>
> Chris
>
Back to top
MSGExpert



Joined: Apr 30, 2006
Posts: 2



PostPosted: Sun Apr 30, 2006 11:25 pm    Post subject: Re: Open msg File to get Attachment details [Login to view extended thread Info.]

MSG Files:

Priasoft has several MSG related products. http://www.priasoft.com

In particular, they have a MSG file parsing library that gives developers access to all the properties of a .msg file, without outlook.

They also have an export library that works with the MSG library for exporting msg files to other formats, like PDF, TIF, and HTML.

For PST files, they have a couple of command line tools that allow extraction of messages to MSG, again without requiring outlook, and it supports both ANSI and UNICODE pst files. There is also the reverse, a MSG to PST utility.

They also have a viewer product that looks very similar to outlook 2003 with regards to the User Interface. The viewer can view, search, print, and export msg files.

Lastly, they just release a free ViewOnly viewer here: http://www.priasoft.com/msgview.exe


Regards,
the MSG Guru, Eriq VanBibber

ALT160 - Do you see me?
Back to top
ncarty97



Joined: Dec 26, 2007
Posts: 1



PostPosted: Wed Dec 26, 2007 2:03 pm    Post subject: Re: Open msg File to get Attachment details [Login to view extended thread Info.]

chris wrote:


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

Chris


When I tried this approach, on a plain text file, it didn't bring in anything for the body. HTML and RTF seemed to work, but not plain text. Any ideas?

Thanks,

Nate
Back to top
saqibrazzaq



Joined: Nov 06, 2008
Posts: 1



PostPosted: Thu Nov 06, 2008 8:09 am    Post subject: [Login to view extended thread Info.]

Hi,

You may also want to try out Aspose.Network component for reading msg files and attachments. Check http://www.aspose.com/documentation/utility-components/aspose.network-...-.net/l for details about how you can parse msg files.
Back to top
Display posts from previous:   
Post new topic   General Reply to Topic (not reply to a specific post)    Forums Home -> Programming VBA All times are: Eastern Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum