Sub SendEmail(ByVal sTo As String, ByVal sSubject As String, ByVal sbody As String, Optional sFile As String, Optional sBlind As String)
On Error GoTo EH_SendEmail
Dim oApp As Outlook.Application
Dim sEmail As String
Dim iPos As Integer
Dim i As Integer
Dim iCount As Integer
Dim oMailItem As Outlook.MailItem
Dim oReceipt As Outlook.Recipient
Dim oAttach As Outlook.Attachment '- use to attach a file
'open Outlook
Set oApp = CreateObject("Outlook.Application")
'Create mail message
Set oMailItem = oApp.CreateItem(olMailItem)
With oMailItem
Set oReceipt = .Recipients.Add(sTo)
oReceipt.Type = olTo
.Subject = sSubject
' .Body = sBody ' changed to be HTML email
.HTMLBody = sbody
'if Blind Copy needed
If Not IsNull(sBlind) And sBlind <> "" Then
.BCC = sBlind
End If
'use to attach a file at sFile
If Not IsNull(sFile) And sFile <> "" Then
Set oAttach = .Attachments.Add(sFile)
End If
'send to outlook outbox
.Send
End With
Set oReceipt = Nothing
Set oAttach = Nothing
Set oMailItem = Nothing
Set oApp = Nothing
Exit Sub
EH_SendEmail:
MsgBox "Error in EH_SendEmail " & Error(Err) & " " & CStr(Err)
Resume Next
End Sub