I have the following functions that are used to generate an Outlook email. It works fine, unless I include an "attach1". Then the email that gets created does not include the attachment I specified as variable "attach1", but instead includes the saved version of the same email.
How can I adjust my code so that I can use .SaveAs and include the "attach1" file?
Code:
Public Function composeLate(appName As String, ticketNum As String, dueDate As String, attach2 As String, eTo As String, Optional ePath As String, Optional eCC As String)
Dim subj As String, body As String, sig As String, attach1 As String, eImp As String
subj = "<REMOVED>"
body = "<REMOVED>"
sig = "<REMOVED>"
attach1 = "\\REMOVED\Test.pptx"
eImp = "olImportanceHigh"
CheckReturn = sendEmail(subj, body, sig, eTo, ePath, , attach2, eCC, eImp)
End Function
Public Function sendEmail(eSubject As String, eBody As String, sig As String, eTo As String, Optional ePath As String, Optional attach1 As String, Optional attach2 As String, Optional eCC As String, Optional eImp As String) As Boolean
Dim outApp As Object, outMail As Outlook.MailItem
Set outApp = CreateObject("Outlook.application")
Set outMail = outApp.CreateItem(0)
With outMail
.To = eTo
.CC = "<REMOVED>;" & eCC
.SentOnBehalfOfName = "<REMOVED>"
.Subject = eSubject
If Not attach1 = "" Then
.Attachments.Add (attach1)
End If
If Not attach2 = "" Then
.Attachments.Add (attach2)
End If
If Not eImp = "" Then
.Importance = olImportanceHigh
End If
.Display
.HTMLBody = eBody & sig
.SaveAs ePath, olMSG
.Display
End With
Set outMail = Nothing
Set outApp = Nothing
End Function
How can I adjust my code so that I can use .SaveAs and include the "attach1" file?