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

email address on form - help! 1

Status
Not open for further replies.

CMcC

Programmer
Feb 5, 2002
196
US
Hi All -
Just trying to make a 'hyperlink' on a form, but want it to go to an email address and invoke the email client. Ive tried to add a hyperlink label, but get syntax error when try to put 'mailto:emailaddres.com" in the click event of the label. Do I need to call createobject? and if so - what is the syntax. Thanks so much

Cmcc
 

Try forum1251. It more suits your question than this one. You might get a better answer there, or you may find that it was already answered somewhere there, either in the threads or in the FAQs.
 
Thanks - I was thinking that since I was trying to create an email link on a visual foxpro form, trying to utilize the hyperlink label - that it would be answered here.
Sorry.
Cmcc
 
Cmcc,

get syntax error when try to put 'mailto:emailaddres.com" in the click event of the label

Just putting the mailto: link in the Click event won't do anything. You need to actually execute the link. One way to do that would be using ShellExecute(). For example:

Code:
lcMail = "mailto:someperson@somewhere.com"
ShellExecute(0,"open",lcMail,"","",1)

This will open the message composing window in the user's default email program, and put the email address in the To field.

In a similar way, you can get it to fill in the Subject, CC, and BCC fields, and the body text. For some more examples, see "An easy way to send email from a Visual FoxPro application", at
Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Thanks to both - Mike and Tamar! Did alittle differently than your suggestions, but this worked -

although - I didnt have the error handler in there and i f the user doenst use Outlook as their mail handler/client - then the foxpro program throws an error and bombs.

So had to throw something in like this:
Code:
merror=0
ON ERROR DO ERRORMSG WITH merror
WAIT WINDOW "Message Being Created. Please Wait" TIMEOUT 2 

#DEFINE MAILITEM 0
#DEFINE IMPORTANCELOW 0
#DEFINE IMPORTANCENORMAL 1
#DEFINE IMPORTANCEHIGH 2

PUBLIC oOutLookObject, OEmailitem
oOutLookObject = CreateObject('Outlook.Application')
oEmailItem = oOutLookObject.CreateItem(MAILITEM)
IF merror=1
  RETURN 0
ENDI
oEmailItem = oOutLookObject.CreateItem(MAILITEM)
WITH oEmailItem
   .Recipients.Add('someone@emailaddress.com') && uses the Recipients collection
   .Subject = 'Data Dictionary'
   .Importance = IMPORTANCENORMAL
   .display
ENDWITH
RELEASE oEmailItem
RELEASE oOutLookObject
ERRORMSG.prg
Code:
lparameters merror
= MESSAGEBOX("You Are Trying To Send An Automated Email With Software " + ;
  space(10)+chr(13)+chr(13)+ ;
  "That is Not Installed On Your Computer"+ ;
  " - Please use your regular email client to email someone@emailaddress.com"+ ;
  chr(13),0+16+0,"System Message")
merror=1
RETURN

thanks again!
CMCC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top