BrainDiseasee
New Member
- Joined
- Aug 30, 2023
- Messages
- 22
- Office Version
- 365
- Platform
- 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
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