Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 6th, 2005, 09:22 AM
Authorized User
 
Join Date: Sep 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to open .msg file in VB

Hi all,

I have a .msg file which are from outlook. I want to open it in VB. Could anybody give me some ideas?

Thanks in advance,
Haiying

 
Old April 11th, 2005, 07:55 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

dim x as Long
x = Shell("Outlook.exe /f your_msg_file_spec")

You may have to specify the fully qualified path to "Outlook.exe". If so, then...

x = Shell("""C:\Program Files\..rest of path..\Outlook.exe"" /f your_msg_file_spec")

Pay attention to the quotes (") repeating.

If "your_msg_file_spec" includes spaces, then...

x = Shell("Outlook.exe /f ""your msg file spec""")

your_msg_file_spec must include the full path to the .msg file.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
http://www.pnwadg.org
 
Old April 25th, 2005, 10:28 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to bwomp99
Default

When I use this line, it opens outlook, but it does not open the message I have listed after /f. Here is my code:

X = Shell("C:\Program Files\Microsoft Office\OFFICE11\Outlook.exe /f" & strFileName)

Where strFileName is the path & file name
   (e.g. c:\emails\message1.msg)

Any thoughts?

Also - is there a way to check to see if Outlook is already running? I think this creates another instance of Outlook.


 
Old April 25th, 2005, 10:35 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to bwomp99
Default

I just realized some of my file names have spaces, so I changed the code to this:

X = Shell("C:\..path..\Outlook.exe /f '" & strFileName & "'")

And I receive this error from Outlook:
 when Outlook is running:
     "The Command Line Argument Is Not Valid. Verify the switch you are using"

 when Outlook is not running:
     "Cannot start Outlook. The Command Line Argument Is Not Valid. Verify the switch you are using"



 
Old April 25th, 2005, 05:10 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Try
Code:
    X = Shell("C:\..path..\Outlook.exe /f """ & strFileName & """")
 
Old April 26th, 2005, 10:08 AM
Registered User
 
Join Date: Apr 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to bwomp99
Default

I had to play around with the quotes, but I did manage to get it working late last night. Here is how it ended up if anyone needs it:

strApp = """C:\Program Files\Microsoft Office\OFFICE11\Outlook.exe"

X = Shell("" & strApp & """ /f """ & strFileName & """")


Even just looking at it, it doesn't seem correct, but it worked.


 
Old April 29th, 2005, 07:46 AM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post
Default

I hate to say I told you so...

Oh, what the hell...

I told you to pay attention to those quotes.:D

The most correct syntax...

strApp = "C:\Program Files\Microsoft Office\Office11\Outlook.exe"
X = Shell("""" & strApp & """ /f """ & strFileName & """")

Notice that you put the frontend quote when you set strApp and the backend quote in the Shell statement. The double quote at the front of your Shell, before the first ampersand (&), does nothing.

An alternative:
strApp = """C:\Program Files\Microsoft Office\Office11\Outlook.exe"""
if instr(strFilename," ") > 0 then strfilename = """" & strfilename & """"
X = Shell(strApp & " /f " & strfilename)

Of course this all fails if strFileName has a quote in it. Windows doesn't allow you to use quotes in file names. But if users can input the file name, it's worth making sure they don't use an invalid file name.
 
Old April 21st, 2006, 05:40 AM
Registered User
 
Join Date: Apr 2006
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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?
 
Old February 16th, 2008, 10:23 AM
Registered User
 
Join Date: Feb 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to saqibrazzaq
Default

Hi,

Check out http://www.aspose.com/Products/Aspose.Network/

They offer reading outlook msg files and a bunch of other network stuff too.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to open excel file thru vb.net sreeramulu Javascript 5 December 6th, 2013 04:19 AM
Open .msg / .eml file in Browser/placeholder withi ai4u Other Programming Languages 3 October 13th, 2006 10:42 AM
Open File with .eml,.msg extension in IE sanjaykp ASP.NET 1.0 and 1.1 Professional 2 April 29th, 2006 02:23 AM
Open .msg / .eml file in Browser/placeholder withi ai4u ASP.NET 1.0 and 1.1 Professional 0 April 28th, 2006 12:36 AM
How to open fdf file through browser in vb technoyogi VB How-To 2 March 15th, 2006 03:22 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.