Public Sub prcSendMail(pstrFrom As String, pstrRecipient As String, pstrSubject As String, pstrBody As String, Optional pstrAttachPath As String = "", Optional pstrCC As String = "", Optional pstrBCC As String = "") ' Send email using CDOEX/CDOSYS
Const conCDOSendUsingPort As Integer = 2
Const conCDOSMTPServer As String = "NAMEOFYOURSMTPSERVER"
Dim objCDOConfig As CDO.Configuration
Dim objCDOMessage As CDO.Message
Set objCDOConfig = New CDO.Configuration
objCDOConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = conCDOSendUsingPort
objCDOConfig.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = conCDOSMTPServer
objCDOConfig.Fields.Update
Set objCDOMessage = New CDO.Message
Set objCDOMessage.Configuration = objCDOConfig
objCDOMessage.AutoGenerateTextBody = True
objCDOMessage.From = pstrFrom ' The address listed as "From"
objCDOMessage.To = pstrRecipient ' The address listed as "To"
objCDOMessage.Subject = pstrSubject ' Specify the subject header
objCDOMessage.HTMLBody = pstrBody ' Specify the body content
If pstrAttachPath <> "" Then objCDOMessage.AddAttachment pstrAttachPath ' Attach specified file, if any
If pstrCC <> "" Then objCDOMessage.CC = pstrCC
If pstrBCC <> "" Then objCDOMessage.BCC = pstrBCC
objCDOMessage.Send
Set objCDOMessage = Nothing
Set objCDOConfig = Nothing
End Sub