Alternatively, if you want to program Outlook
to send an email, you could do it like this:
Sub SendEmail()
' Assumes reference to Outlook Object Library
' (Set in vba editor, on Tools, References menu).
On Error GoTo HandleErrors
Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objMI As Outlook.MailItem
Set objOL = New Outlook.Application
Set objNS = objOL.GetNamespace("MAPI")
' If using email server, allow user to logon
' (Ignored if already logged on or if not
' using server):
objNS.Logon , , True, False
Set objMI = objOL.CreateItem(olMailItem)
With objMI
.To = "Recipients Email Address Here" & ""
.CC = "Carbon Copies (Email Addresses) Here"
.BCC = "Blind Copies (Email Addresses) Here"
.Subject = "Subject Text Here"
.Body = "Message Text Here"
.Display
' Instead of displaying message,
' you could send immediately:
' .Send
End With
Bye:
Set objMI = Nothing
Set objNS = Nothing
Set objOL = Nothing
Exit Sub
HandleErrors:
MsgBox Err.Description, vbOKOnly, "Error No: " & CStr(Err.Number)
Resume Bye
End Sub
You may find it more convenient to pass the variable
data (eg To) to the subprocedure, eg
Sub SendEmail(varTo as Variant, etc., etc.)
Then later:
With objMI
.To = varTo & ""
etc, etc.
For further information:
www.slipstick.com
Regards
Geoff