VBA change to not show a sent email in outlook

Dspace

New Member
Joined
Nov 2, 2020
Messages
24
Office Version
  1. 365
Platform
  1. Windows
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
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
In my opinion, sending an email using somebody else's account without their consent is more than a little wrong. Sorry for sounding like a goody two shoes. Stay on the high road.
 
Upvote 0
In my opinion, sending an email using somebody else's account without their consent is more than a little wrong. Sorry for sounding like a goody two shoes. Stay on the high road.
While normally I’d agree with you I’ve been tasked with auditing sales rep behavior & their tendency to manipulate pricing for the good of their commission statements while not necessarily at the good of the company’s bottom line.
 
Upvote 0
The change works for me: the email is sent and received by the recipient and it doesn't appear in the sender's Sent Items or Deleted Items folder.
 
Upvote 0
The change works for me: the email is sent and received by the recipient and it doesn't appear in the sender's Sent Items or Deleted Items folder.
I just rechecked it with a different email address in the sent command & still no success. I wonder if this is due to my company's security settings. I'm might have to attack this problem from a different direction.

I do appreciate your suggestions. Thanks for trying.
 
Upvote 0

Forum statistics

Threads
1,223,710
Messages
6,174,017
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top