Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody, Optional ByVal pvFile) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
'NOTE : YOU MUST HAVE THE OUTLOOK REFERENCE CHECKED IN VBE; ctl-G, menu,tools, references, Microsoft Outlook XX Object library
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.createitem(olMailItem)
With oMail
.To = pvTo
.Subject = pvSubj
If Not IsNull(pvBody) Then .Body = pvBody
If Not IsMissing(pvFile) Then .Attachments.Add pvFile, olByValue, 1
'.Display True
'.Save 'draft, we are NOT sending...we save as draft
.Send
End With
Email1 = True
endit:
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume endit
End Function