VB Code:
Sub SendMail(ByVal ToNames As String, ByVal CCNames As String,_
ByVal vSubject As String, ByVal vMessage As String, _
ByVal AttachFile As String)
Dim OutApp As Object
Dim OutMail As Object
Const olMailItem = 0
' Sends out an Email with vMessage as the body and with the Subject as vSubject
' Sent to ToNames and CCNames, ToNames must not be blank
If ToNames = "" Then
Exit Sub
End If
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = ToNames
.cc = CCNames
.Subject = vSubject
.Body = vMessage & vbCr & vbCr
If AttachFile <> "" Then
.Attachments.Add AttachFile
End If
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub