VBA Email Outllook Item .Send does not work

BrainDiseasee

New Member
Joined
Aug 30, 2023
Messages
22
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am working with a macro to send an email, i can get the email to draft and display. But the .Send doesnt seem to work. I essentially am needing this to just automatically send with no display or screen updating. I'll share my code below, any help is greatly appreciated, thanks.

Sub SendStatus()

Dim OutApp As Object
Dim Outmail As Object
Dim strbody As String
Dim name As String
Dim status As String
Dim Email As String
Dim Project As String
Dim Tollgate As String



Dim ws As Worksheet
' With Application
' .EnableEvents = False
' .ScreenUpdating = False
' End With
Set OutApp = CreateObject("Outlook.Application")
Set Outmail = OutApp.CreateItem(0)
Set ws = ActiveSheet

Project = ws.Cells(21, 3).Text
name = ws.Cells(39, 8).Text
Email = ws.Cells(39, 9).Text
status = ws.Cells(39, 11).Text
Tollgate = ws.Cells(39, 12).Text


strbody = "<HTML> <Body>"
strbody = "Hello," & "<p>" & Project & " " & Tollgate & " status has been changed to " & status & "."
strbody = strbody & "</body> <HTML>"




On Error Resume Next

With Outmail
.to = Email
.CC = ""
.BCC = ""
.Subject = "Project Status Update: " & Project & " " & Format(Date, "mm-dd-yy")


.htmlbody = strbody & vbCrLf
.Display

.Send

End With

On Error GoTo 0

Set Outmail = Nothing
Set OutApp = Nothing






End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Your email security settings are what is most likely causing the issue. In outlook>>File tab>>Options>>Trust Center>>Trust Center settings>>Programmatic Access
 
Upvote 0
Doesnt look like i can change anything due tom y companies security but is this what im supposed to be looking at?
1694546789147.png
 
Upvote 0
If you can't change it, it means you don't have administrative rights. You would have to contact your I.T. Dept, but they aren't likely to give you access. You would have to turn it off completely.
 
Upvote 0
Solution

Forum statistics

Threads
1,215,072
Messages
6,122,968
Members
449,095
Latest member
Mr Hughes

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