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

E-Mail vs. VFP

Status
Not open for further replies.

JayPeg

Programmer
Jun 10, 2002
4
DE
Hello,

i want to automate my E-mail with VFP!
How can i use Outlook Express to send an Email?
Createobject() dosen´t work...
I would be greateful if you could give me some examples!

Thank you!
 
Outlook Express is not a COM server and cannot be automated. But if the default E-mail programm is Outlook Express this will work:
Code:
DECLARE INTEGER ShellExecute IN shell32.dll ; 
  INTEGER hndWin, STRING cAction, STRING cFileName, ; 
  STRING cParams, STRING cDir, INTEGER nShowWin

lcMail = "mailto:john@mycompany.com"+ ;
  "?CC= boss@mycompany.com&Subject= Meet for lunch"+ ;
   "&Body= Please join me for a sandwich at noon." 
ShellExecute(0,"open",lcMail,"","",1)

 
Thank You!
That was exactly what i needed!
But now Outlook Express opens a Mail an i have to click on the send Button! Can i send that mail totally automatically??
Can you explain me what exactly the parameters of shellExecute(0,"open",lcMail,"","",1) stand for??
 
you can also use activeX controls. you can add them through your options box. once they are added to the toolbar drag them on to the form or create them programaticaly.

How to send e-mail using MAPI session

* Create an instance of a form, and then add the MSMAPI.MAPISession and
* MSMAPI.MAPIMessages OLE controls to that form:

oform = CreateObject("form")
oform.addobject("Session1","olecontrol","MSMAPI.mapiSession")
oform.addobject("Message1","olecontrol","MSMAPI.mapiMessages")

* Call the Signon method of the MAPISession control. If the user is not
* logged into mail, this will prompt the user to sign on. This also sets
* the SessionId property for the MAPIsession control:

oform.Session1.signon

* Set the SessionId of the MAPIMessage control to the SessionId of the
* MAPISession control, which was just obtained:

oform.Message1.sessionid = oform.Session1.sessionid

* Compose an e-mail message and set the subject line and Message text:

oform.Message1.compose
oform.Message1.msgsubject = "Memo from my FoxPro app"
oform.Message1.msgnotetext = "This works"

* Sends the e-mail message. The (1) is required to send the message.

oform.Message1.send(1)

* Optionally, sign off from mail:

oform.Session1.signoff

* Optionally, release the objects if they are no longer needed:

release oform
Attitude is Everything
 
JayPeg,

According the docs that came with the example, here are the limitations:

This technique has a couple of obvious limitation. First, it is not suitable for creating very long messages or messages with formatted text. Nor is it possible to add attachments to the message. More seriously, you have to rely on the user to actually send the message. You can't do that programmatically, nor can you prevent the user from cancelling the message rather than sending it.

On the other hand, if all you need is a simple way of helping the user to compose and send an unformatted message without attachments, the technique will work extremely well. You could use it, for example, to create a message which confirms an order or one which chases a customer for payment. It is especially useful if you want to let the user edit the text before hitting the Send button.

Mike Lewis Consultants Ltd. February 2002



 
German12

The code refers to CDO.dll (Which might be available or not on the client's system since it came with Office 2002 or Windows XP)
 
You may investigate the "proper" Windows way (before Microsoft created Outlook and encouraged Outlook automation to tie people to M$ products....) and use MAPI .. the Messaging Application Programming Interface.

See faq184-1769 For an example of how to do so.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top