How To Send Email Programmatically by Using MSMAPI OLE ControlLast reviewed: October 18, 1996Article ID: Q136638 |
The information in this article applies to:
SUMMARYThis article shows by example how to can gain access to the MSMAPI OLE controls programmatically by using the CREATEOBJECT() function to create an instance of a form and the AddObject method to create an instance of the controls. Then you can work with the methods and properties of the controls programmatically. Note that although the .ocx control must be placed on a form, the form itself never has to be visible as is the case in the example given in this article.
MORE INFORMATION
Code Sample* 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 email 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 email message. The (1) is required for the message to be sent. oform.Message1.send(1) * optionally, sign off from mail: oform.Session1.signoff * optionally, release the objects if they are no longer needed: release oform NOTE: The Session and Message controls continue to exist as long as the variables oSession and Omessage are in scope. These variables may be declared as public to ensure that the controls are available throughout the entire application.
|
Additional reference words: 5.00 3.00 VFoxWin MAPI e-mail mail
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |