Tell It to the Grapevine: MAPI, OLE Messaging
What is the minimal amount of code used to send a MAPI message to the Internet without a user interfacei.e., default user id, and default message.
Rick Hopkin
Automatic messages! My cost accountant is very happy!
There are several ways to automate the process of sending a message in Visual Basic. You can use the MAPI controls, direct MAPI calls, or OLE Messaging.
There are two common approaches to using MAPI from Visual Basic 4.0.
 Use the MAPI controls that come with the Professional and Enterprise editions of Visual Basic 4.0. VBMAIL.VBP, a sample project that comes with Visual Basic, demonstrates the use of the MAPI controls.
 Use the OLE Messaging Object Library to manipulate messages, attachments, folders, and addresses in Microsoft Exchange.
Here is an example of using OLE Messaging to send a message:
Dim oSession
As Object 
  
Set
oSession = CreateObject("MAPI.Session") 
oSession.Logon
"MS Exchange Settings", True 
Dim
objMessage As Object ' Message object 
Dim
objOneRecip As Object ' Recipient object 
  
If
oSession Is Nothing Then 
MsgBox
"You have to log on first...." 
Exit Sub 
End If 
  
Set
objMessage = oSession.Outbox.Messages.Add 
' create
the recipient 
Set
objOneRecip = objMessage.Recipients.Add 
objOneRecip.Name
= "Rickcau@Microsoft.com" 
objOneRecip.Type
= mapiTo 
objOneRecip.Resolve
(True) 'Show dialog to resolve ambiguities 
With
objMessage ' message object 
.subject
= "Test MAPI/OLE VB Message w/ole object - explicit" 
.Text =
"Like you really wanted this ... please delete this
test" 
End With 
' send
the message 
objMessage.Send
showDialog:=False 
For more information on direct MAPI calls and OLE Messaging, in the MSDN Library, see the book Win32 Messaging API (MAPI) in the Win32 SDK.