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

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
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,224,809
Messages
6,181,075
Members
453,020
Latest member
mattg2448

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