Article ID: 175052
Article Last Modified on 7/13/2004
171440 Where to Acquire the Collaboration Data Objects Library
* AM_BareBones.PRG
* ----------------
*
*Create a MAPI Session object then Logon. The Logon dialog can be
*bypassed by providing a valid ProfileName as the first parameter
*(as a string) to the Logon Method.
objSession = CREATEOBJECT("mapi.session")
objSession.Logon
*Create a new message in the Outbox
objMessage = objSession.Outbox.Messages.Add
*Populate a few basic properties of the message
objMessage.Subject = "This is the subject"
objMessage.Text = "This is the message text"
*Add a Recipient to the message we just created and resolve
objRecip = objMessage.Recipients.Add
*Alias of who you are sending to
objRecip.name = "TargetEmailName"
objRecip.Resolve
*Send it
objMessage.Send
*Clean up then bail
objSession.Logoff
RELEASE objRecip, objMessage, objSession
*EOP: AM_BareBones.PRG
The second sample is similar to the first except that it adds an attachment
to the outgoing message. This sample also demonstrates a few alternate ways
that the same functionality can be accomplished without using the same
code. For instance, logging on and passing a ProfileName instead of getting
prompted to enter one, or the slightly different manner in which the
recipient is added.
* AM_Attachments.PRG
* ------------------
*
*Create a MAPI Session object then Logon. The Logon dialog can be
*bypassed by providing a valid ProfileName as the first parameter
*(as a string) to the Logon Method as seen below.
objSession = CREATEOBJECT("mapi.session")
objSession.Logon("YourProfileName")
*Create a new message in the Outbox and populate a few basic properties
objMessage = objSession.Outbox.Messages.Add
objMessage.Subject = "Visual Fox Active Messaging Sample - Attachments"
objMessage.Text = "This is the message text."
*Add an attachment (assumes "myfile.doc" exist in c:\)
objMessage.Attachments.Add("MyFile.doc", 0, 1, "c:\myfile.doc")
*Add a Recipient to the message we just created and resolve
objRecip = objMessage.Recipients.Add("TargetsEmailName") && who it's to
objRecip.Resolve
*Send it
objMessage.Send
*Clean up then bail
objSession.Logoff
RELEASE objRecip, objMessage, objSession
*EOP: AM_Attatchments.PRG
Additional query words: Active Messaging
Keywords: kbhowto kbcode KB175052