Good day. I'm writing in VBA to run a macro & a sub-routine to send an email behind the scenes. The only problem is I want it sent without it showing up in the users Sent Box. Can I edit the below to accomplish this? Every time I test it myself it's still showing in my Sent box. Thanks
Sub SendEmail(macroName As String)
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim cellValue As String
' Determine the appropriate cell based on the active sheet name
Select Case ActiveSheet.Name
Case "worksheet1", "worksheet2"
cellValue = ActiveSheet.Range("B4").Value
Case Else
cellValue = ActiveSheet.Range("B5").Value
End Select
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.To = "user@user.com"
.Subject = "BA executed pricing for " & cellValue
.Body = "Customer: " & cellValue
.Attachments.Add ThisWorkbook.FullName
.Send
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub
Sub SendEmail(macroName As String)
Dim OutlookApp As Object
Dim OutlookMail As Object
Dim cellValue As String
' Determine the appropriate cell based on the active sheet name
Select Case ActiveSheet.Name
Case "worksheet1", "worksheet2"
cellValue = ActiveSheet.Range("B4").Value
Case Else
cellValue = ActiveSheet.Range("B5").Value
End Select
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
With OutlookMail
.To = "user@user.com"
.Subject = "BA executed pricing for " & cellValue
.Body = "Customer: " & cellValue
.Attachments.Add ThisWorkbook.FullName
.Send
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub