EliseFreedman
Programmer
Hi there
I am using the code below to send email through excel. It works like a dream apart from the fact that It opens up every email and waits for me to go into the message and hit the send button. I would like it to just send all the messages automatically without any intervention from the user. Can anyone tell me where im going wrong
Elise
I am using the code below to send email through excel. It works like a dream apart from the fact that It opens up every email and waits for me to go into the message and hit the send button. I would like it to just send all the messages automatically without any intervention from the user. Can anyone tell me where im going wrong
Elise
Code:
Sub SendOutlookEmail()
Dim objol As New Outlook.Application
Dim objmail As MailItem
Set objol = New Outlook.Application
Dim r As Integer, x As Double
Sheets("Actions Tracking Report").Select
For r = 2 To 40
If Cells(r, 4).Text = "Actions Outstanding" Then
Set objmail = objol.createitem(olmailitem)
With objmail
.To = Cells(r, 7)
.Subject = "Outstanding Actions from HRO Reference " & Cells(r, 5).Text
.Body = "Dear " & Cells(r, 8) & _
vbCrLf & vbCrLf & "I am emailing to advise you that you have the following action outstanding " & vbCrLf & vbCrLf _
& Cells(r, 6).Text & vbCrLf & vbCrLf & _
"Please complete the action as soon as possible" & vbCrLf & vbCrLf & _
"Please ensure that on completing your action, you update the actions status in the Smarter Database by opening up the link below" & vbCrLf & vbCrLf & _
"[URL unfurl="true"]http://appsvr1.collaborate.sharelnk.net/sMARTer2/"[/URL] & vbCrLf & vbCrLf & _
"The action should be completed by " & Cells(r, 3).Text & vbCrLf & vbCrLf & _
"Thank you for your cooperation " & vbCrLf & vbCrLf & _
"Elise Freedman" & vbCrLf & vbCrLf & _
"Health and Safety Department"
.NoAging = True
.display
End With
Set objmail = Nothing
Set objol = Nothing
SendKeys "%{s}", True 'send the email without prompts
End If
Next r
End Sub