Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About Shellexecute & Why? 1

Status
Not open for further replies.

keepingbusy

Programmer
Joined
Apr 9, 2000
Messages
1,470
Location
GB
In a recent FAQ I posted some code to assist in sending info to an email using Oulook Express Version 6. No problems, all is working fine.

What I'm not sure about is what actually starts up OE6?

With my code...

Code:
LOCAL cEmail, mconv1, more variables....

Then.......

Code:
DECLARE integer ShellExecute IN shell32.dll ;
integer hndWin, string cAction, string cFileName, ;
string cParams, string cDir, integer nShowWin

cEmail = "mailto:"+LOWER(TRIM(mcdxemail))+ ;
"?Subject=Order Request"+ ;
"&Body="+mconv1+chr(10)+chr(10)

Then.......

Code:
ShellExecute(0,"open",cEMail,"","",1)
CLEAR DLLS ShellExecute

Looking around the forum, I found some examples of how to launch apps, such as: thread184-747645 (Part code) includes:

Code:
DECLARE INTEGER ShellExecute IN "Shell32.dll" ;
    INTEGER hwnd, ;
    STRING lpVerb, ;
    STRING lpFile, ;
    STRING lpParameters, ;
    STRING lpDirectory, ;
    LONG nShowCmd
=Shellexecute(0,"Open","c:\mypdffile.pdf","","",1)

... posted by mgagnon. I understand this as a file name is shown associated with an app (.pdf Adobe Reader).

My confusion here is what is telling Outlook Express 6 to open in my code when all I see is:

Code:
[b]ShellExecute(0,"open",cEMail,"","",1)[/b]

Is it cEMail? Again this doesn't make sense because the command line for OE6 is:

"C:\Program Files\Outlook Express\msimn.exe"

1. Why does it do this?
2. If I were to change my source code and ask it to open up Microsoft Outlook (C:\Program Files\Microsoft Office\Office\outlook.exe) what do I need to do?

Many thanks
Lee.....

Alone we can do so little, together we can do so much
 

1. Why does it do this?

ShellExcute is an API call that says "Do want ever command is contained in the second parameter against the thrid parameter", so the key to the your question is the "mailto:" wich triggers Outlook Express.

2. If I were to change my source code and ask it to open up Microsoft Outlook (C:\Program Files\Microsoft Office\Office\outlook.exe) what do I need to do?

Since Outlook is a COM server, it does permit more flexibility, you have some examples in the faq184-3894. I'm not sure you could send a one-line to trigger outlook.




Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 

Alhtough this has a similar effect if Outlook is set as your default e-mail program.

Code:
DO FindWindow
LOCAL lcPath, hWindow, lcDelimiter, lcFiles, lcMsgSubj 
lcPath = SYS(5) + SYS(2003) 
hWindow = GetActiveWindow() 
lcDelimiter = ";" 
lcFiles = "" 
lcMsgSubj = "This is a test." 
= MAPISendDocuments (hWindow, lcDelimiter, lcFiles, lcMsgSubj, 0) 
SET DEFAULT TO (lcPath) 
PROCEDURE  FindWindow
    DECLARE INTEGER GetActiveWindow IN user32 
    DECLARE INTEGER MAPISendDocuments IN mapi32; 
        INTEGER ulUIParam, STRING lpszDelimChar,; 
        STRING lpszFullPaths, STRING lpszFileNames,; 
        INTEGER ulReserved 
ENDPROC

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike,

mgagnon said:
I'm not sure you could send a one-line to trigger outlook

Just to let you know, it also work with Outlook as long as it is the default e-mail. Lee's FAQ works on my machine (VFP7 & Outlook2000)

-- AirCon --
 
Mike

Tried your code and yes, it "boots up" my default email software being Microsoft Outlook 6. The whole issue with this project was the fact (at first) I was unable to send the one liner. As you'll see I've now posted an address where anyone can pick up the working example.

The good thing about your code Mike is that I've changed one line:

lcFiles = ""
to
lcFiles = "C:\WINDOWS\DESKTOP\MYFILE.XLS"

which could be a way of me resolving the problem when someone uses Microsoft Outlook instead of Outlook Express.
I'm thinking here the result already produced can be exported to a file, your code could be used to attach that file and away we go so to speak.

Does that make sense?

Aircon, what are your thoughts?

Kindest regards
Lee....

Alone we can do so little, together we can do so much
 

which could be a way of me resolving the problem when someone uses Microsoft Outlook instead of Outlook Express.
I'm thinking here the result already produced can be exported to a file, your code could be used to attach that file and away we go so to speak.


In fact if you look at my faq184-2413 (which I modifed toi post here), you can in fact attach more then one file to it.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Mike

Perfect! I changed the line as you mentioned to:

lcFiles = Getfile() and this solves the problem.

I have rated your FAQ so thanks again to you

Lee

Alone we can do so little, together we can do so much
 
Mike

In furtherance to this thread I've just tried your suggestion shown at thread184-786513 and set my default email client as Microsoft Outlook

With a few amendments this is just what I'm looking for so once again, my sincere thanks to you

Lee

Alone we can do so little, together we can do so much
 
Keepingbusy

With a few amendments this is just what I'm looking for so once again, my sincere thanks to you

Glad you worked it out.


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top