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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vfp 8 and shellexecute

Status
Not open for further replies.

jayjay555

Programmer
May 4, 2009
13
CA
hi all,

I have this code which works fine except it doesn't actually send the email address. It waits there and the user has to press "ALT-S" to send. Can someboday please help and how to solve it. here is the code:

DECLARE INTEGER ShellExecute IN shell32.dll INTEGER hndWin, STRING cAction, STRING cFileName, STRING cParams, STRING cDir, INTEGER nShowWin
lcMail = "mailto:jj@kk.com"+ "&Body= Please join me for a sandwich at noon."
ShellExecute(0,"open",lcMail,"","",1)


all I need foe it to do is actualyl send it now. can somebody please help.

thanks,
jj
 
JJ,
This code that works fine for me.
It opens outlook and fills in the adress.
Is that what you are looking for?
-Bart

DECLARE INTEGER ShellExecute IN shell32.dll INTEGER hndWin, STRING cAction, STRING cFileName, STRING cParams, STRING cDir, INTEGER nShowWin

ShellExecute(0,"open","mailto:"+allt('email-adress'),"","",1)
 
In addition:
faq1251-4969
This sends emails without use of outlook.
-Bart
 
JJ,

Your code does exactly what it is intended to do: Open a message composing window in the user's default email client.

If you want to force it to actually send the message, you'll need to add a bit of code.

Something like this:

Code:
oWsh = CREATEOBJECT("wscript.shell")

DECLARE INTEGER ShellExecute IN shell32.dll ;
  INTEGER hndWin, STRING cAction, STRING cFileName, ;
  STRING cParams, STRING cDir, INTEGER nShowWin

lcMail = "mailto:jj@kk.com" + ;
  "?Subject=Lunch&Body=Join me for a sandwich."

ShellExecute(0,"open",lcMail,"","",1)

* Give it a moment to be launched
WAIT TIMEOUT 1

* Switch to the message window
oWsh.AppActivate("Lunch")

* Send Alt-F, E to send the message
oWsh.Sendkeys("%fe")

* Release oWsh
RELEASE oWsh

Note that the message title has to match the window title in AppActivate() call.

Also, I note you missed out the question mark in the message parameters. If you look back at the article where you got the code ( you'll see this:

Code:
lcMail = "mailto:john@mycompany.com"+ ;
  "[b]?[/b]CC= boss@mycompany.com&Subject= Meet for lunch"+ ;
   "&Body= Please join me for a sandwich at noon."

I think you'll find that will work.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Yes, the following code works:

DECLARE INTEGER ShellExecute IN shell32.dll INTEGER hndWin, STRING cAction, STRING cFileName, STRING cParams, STRING cDir, INTEGER nShowWin
lcMail = "mailto:jj@jj.com"+ ;
"?CC= jj@jj.com&Subject= Meet for lunch"+ ;
"&Body= Please join me for a sandwich at noon."
ShellExecute(0,"open",lcMail,"","",1)


BUT it doesn't 'send' it. the user has to click on 'send'. How can I make it automatically send as well. That's my problem. Please help.


thanks,
jj
 
JJ
As i said before:
FAQ1251-4969: How to send e-mail using CDO and checking the connection status first.
This is what you are looking for!!
-Bart
 
hi Mike,

Yes, I know and I have it. Thank You. Greatly apprecaited.

BUT I was just wondering what the "http" stuff is in there for exacttly?

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top