use of application.executeProgram

Hi Guys,
I’m calling outlook in a method, so someone sending mail to a person can automatically open up their outlook new message screen at the touch of a button. I can open Outlook without any problem, but using a commandline switch is proving to be quite the headache. Not being a programmer doesn’t help either.

Heres the simple code I use.

if(utils.stringMiddle(application.getOSName(),1,7) == “Windows”)
{
application.executeProgram(‘c:/program files/Microsoft Office/OFFICE11/outlook.exe’,’ /c imp.note’)
}

When I use this I get an error from outlook stating that the command line argument is not valid. Verify the switch you are using.

In a command window the switch is called like this

“c:/program files/microsoft office/office11/outlook.exe” /c imp.note,

however when I duplicate the command by enclosing the switch in quotes I get the error message.

It seems that the command line switch doesn’t like quotes and that’s how the executeProgram function is geared. Is there a way I can pass the parameter to the program without quotes?

Thanks a ton,
Graham

Hi Graham,

I don’t know about outlook command line params, but when you call paths with spaces in Windows OS you need to enclose the in parenthesis, thus command line:

“c:/program files/Microsoft Office/OFFICE11/outlook.exe”

becomes:

application.executeProgram(‘c:/program files/Microsoft Office/OFFICE11/outlook.exe’); // note single quotes surrounding double quotes!

Assuming the command line switch is correct this should do the trick.

Miguel

Thanks Miguel,
Thanks for the reply, which I tried, but got an illegal instruction error, generated by servoy.

If I just use the command to start Outlook, there is no problem - Outlook starts, but then the user has to click on new to start a new message.

It seems the executeProgram function passes the switch to outlook enclosed in quotes, which generates the error invalid command line switch, which is generated by outlook.

What I’m trying to do is strip the quotes from around the command line switch so it appears to Outlook as if it came from a command prompt window.

I think the problem is associated with the way windows does things versus the normal world, so this may not be a possibility.

Graham

Hi Graham, why don’t you simply use:

application.showURL('mailto:user@host.com')

or:

application.showURL('mailto:' + email)

where email is a var or field with the email address of the intended recipient ?
This way you have a fully cross-platform solution: showURL will open the default email client in Windows/MacOS/Linux. No problem if they are using Eudora or Mail or if Outlook is not installed in the standard path.[/code]

Hi Graham,

I fidled a bit more with it and the error message I get is always from the OS, not from Servoy. Looked around and found that we are misspeling the switch! Instead of:

"/c imp.note"

Use:

"/c ipm.note"

;-)

Glad to be of help.
Miguel

Thanks Guys,
It may help if I could type… Thanks for both replies, they have helped me a lot.

Graham

You can also use the office plugin to do everything you want to do with Outlook via Servoy.

Cheers