Create a new module and paste this source code into it. Change the name of the module to basOutlook. If you have any questions, email us at help@codeoftheweek.com
'----------------------------------------------------------------------
'
' Module Name: basOutlook
' Written By: C&D Programming Corp.
' Create Date: 11/99
' Copyright: Copyright 2000 by C&D Programming Corp. Source
' code may not be reproduced except for use in a
' compiled executable. All rights reserved. If
' you would like to reprint any or all of this
' code please email us at info@codeoftheweek.com
'----------------------------------------------------------------------
Option Explicit
Public Sub OutlookSendMessage(sRecipient As String, sSubject As String, _
sMessage As String, _
Optional eImportance As OlImportance = olImportanceNormal)
Dim olApp As Outlook.Application
Dim olMessage As Outlook.MailItem
On Error GoTo Handler
Set olApp = New Outlook.Application
Set olMessage = olApp.CreateItem(olMailItem)
' call the following line multiple times to add multiple recips
olMessage.Recipients.Add sRecipient
olMessage.Subject = sSubject
olMessage.Body = sMessage
' define the importance of the message
olMessage.Importance = eImportance ' (or Low or Normal)
olMessage.Send
Set olMessage = Nothing
Set olApp = Nothing
Exit Sub
Handler:
Err.Raise Err.Number, "SendOutlookMessage", Err.Description
End Sub