Macro stopped working

blimey88

New Member
Joined
Aug 20, 2019
Messages
38
Good afternoon all,

I have created a simple macro that creates an email, and all of a sudden it has stopped working? Any ideas as to why it would just stop working?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Any specific error messages? Are you using a google account to send the emails?
 
Upvote 0
of course

Sub send_hyperlink_with_variable()

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim name As String
Dim link As String
Dim email As String
Dim area As String
Dim sh As Worksheet
Dim dtDate As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set sh = ThisWorkbook.Sheets("Royal London")

'name = sh.Cells(1, 2).Text
link = sh.Cells(1, 3).Text
email = sh.Cells(1, 4).Text
area = sh.Cells(1, 5).Text
dtDate = Format(Now() + 7, "dd mmmm yyyy")
'MsgBox dtToday

strbody = "<BODY style = font-size:12pt; font-family:Arial>" & _
"Hello " & name & ", <p> Your Health, Safety & Wellbeing Inspection of the following area needs completing - " & area & "! " & _
"Please complete this by " & dtDate & " " & _
"<a href=""" & link & """>click here for your blank inspection form.</a><P>" 'Use 3No. speech marks for the full link, 1No. will only give you the until the first space

On Error Resume Next
With OutMail
.to = email
.CC = " Benjamin.Pollard@skanska.co.uk "
.BCC = ""
.Subject = "Health, Safety & Wellbeing Inspection Due"
.Attachments.Add "P:\02.0 - Health & Safety\2.5 H&S Monitoring\Royal London Hospital\1. RLH Inspection Rota 2021\RLH Inspection Rota October 2021 - March 2022.xlsx"
.Display
.HTMLBody = strbody & .HTMLBody

End With
On Error GoTo 0

Set OutMail = Nothing
Set OutApp = Nothing


End Sub
 
Upvote 0

Forum statistics

Threads
1,223,885
Messages
6,175,187
Members
452,616
Latest member
intern444

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