Previous Topic

Next Topic

Book Contents

Book Index

Home Page

Sending E-Mail with a COM Compliant Client

The basic procedure for sending mail with a client that supports COM is as follows:

The sample code below shows how to compose a short message using Microsoft Outlook 98 or 2000. Refer to Microsoft Outlook information for more details on scripting Microsoft Outlook.

' Microsoft Outlook object variables.
Dim myolApp, olNameSpace, myFolder, myMailItem
' Try to create an MSOutlook object
Set myolApp = CreateObject("Outlook.Application")
' Set up MAPI name space for mailing
Set olNameSpace = myOlApp.GetNameSpace("MAPI")
' Create a mail item
Set myMailItem = myOlApp.CreateItem(0)
' Set up mail recipient.
myMailItem.To = "someone@somewhere.com"
' Set message subject.
myMailItem.Subject = "Message " + Answer_Phone
' Set the body of the message
myMailItem.Body = "Hello Friend!"
' Send mail to recipients
myMailItem.Send

Files can also be attached to the e-mail message: this opens the possibility for interesting and powerful features such as Forwarding Voice Messages to E-Mail. The Voice Mail to EMail and E-Mail Reader example Call Trees are available in the examples folder for further reference.

See Also

How to Send E-Mail from a Macro

Reading E-Mail from a COM Compliant Client

Sending E-Mail from a Simple Mail Client

Sending E-Mail with Microsoft CDO