Problem opening a msg file using ShellExecute()

J

Javed

Hi,

I am trying to open a outlook msg file programmaticatlly as below in
my C++ code.

ShellExecute(NULL, _T("open"), _T("C:\\Program Files\\Microsoft
Office\\OFFICE11\\OUTLOOK.EXE"), _T("C:\\Test.msg"), NULL, SW_SHOWNORMAL);

It used to work on Outlook 2003 SP2 and before but when I installed
SP3 it is giving following error
"The command line argument is not valid. Verify the switch you are
using.â€

I tried using command line

C:\Program Files\Microsoft Office\OFFICE11>outlook.exe /open "C:
\Test.msg"

It gave me same error message

Anybody has any Idea please
 
K

Karl E. Peterson

Javed said:
I am trying to open a outlook msg file programmaticatlly as below in
my C++ code.

Hmmmmm, so what's your VBA question? (Sounds like MSFT broke your app? That's the
current pattern they're in. They think that stimulates sales. Go figure.)
 
C

Chirag

Try opening the .msg file directly as follows:

ShellExecute(NULL, _T("open"), _T("C:\\Test.msg"), NULL, NULL,
SW_SHOWNORMAL);

If Outlook is configured to open it, it should open the .msg file with the
above ShellExecute() call.

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 
J

Javed

Thanks everybody for reply.

I found the solution and posting it for someone else help.

ShellExecute(NULL, _T("open"), _T("C:\\Program Files\
\Microsoft
Office\\OFFICE11\\OUTLOOK.EXE"), _T("/f C:\\Test.msg") , NULL,
SW_SHOWNORMAL);

Basically it requires a /f switch with the file name
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top