Inserting a link into the body of an email that is automatically generated

AndreaWorkPlace

New Member
Joined
Jan 24, 2022
Messages
5
Office Version
  1. 365
Platform
  1. Windows
  2. Web
HI All.
Apologies if this has been answered but I have been working on this for two days solid now and can's seem to find a solution. I understand its my own lack of experience but and help would be really appreciated. I have written a macro that emails automatically out to someone when a particular date is in 30 days time. The title is populated with the name of the file and the original spreadsheet is updated to show an email has been sent. This all works perfectly! However, I would like to add a link in the body of the email that the person receiving it, can click on to get to the document. I have attached my code and marked in red what I think it should be but evidently it is wrong. My email is still generated but just with the bit of code. I think I need to use the String functionality somewhere but cant seem how to do it. The "13" referred to in this piece of code ie cells (x, 13) is the column number I have put the hyperlink in and should relate to that row. Many thanks everyone!!!!!!!!!

VBA Code:
Sub datesexcelvba()
Dim myApp As Outlook.Application, mymail As Outlook.MailItem
Dim mydate1 As Date
Dim mydate2 As Long
Dim datetoday1 As Date
Dim datetoday2 As Long

Dim x As Long
lastrow = Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For x = 2 To lastrow

mydate1 = Cells(x, 8).Value
mydate2 = mydate1

Cells(x, 11).Value = mydate2
datetoday1 = Date
datetoday2 = datetoday1

Cells(x, 12).Value = datetoday2

If mydate2 - datetoday2 = 30 Then

Set myApp = New Outlook.Application
Set mymail = myApp.CreateItem(olmailitem)

mymail.To = Cells(x, 7).Value


With mymail
   .Subject = "Review Reminder " & Cells(x, 4).Value
   .Body = "Good Morning," & vbCrLf & _
     "Please be aware that this file is due for review in the next 30 days" & vbCrLf & _
     "Regards" & vbCrLf & _
     "Master Control Document"
[COLOR=rgb(209, 72, 65)]'  "Please click " & " <a href = Sheets (Sheet1).Cells (x, 13).Value "">Here</A >"[/COLOR]
    
   .Display
'.send
End With
Set myApp = Nothing
Set mymail = Nothing



Cells(x, 9) = "Yes"
Cells(x, 9).Font.ColorIndex = 3
Cells(x, 9).Font.Bold = True

Cells(x, 10).Value = mydate2 - datetoday2

End If
Next
Set myApp = Nothing
Set mymail = Nothing


End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Apologies I thought the colour would show. The pieve of code I refer to is

"Please click " & " <a href = Sheets (Sheet1).Cells (x, 13).Value "">Here</A >"

It shouldn't be commented out

Thank you!
 
Upvote 0
int or exttype of documentversion numberTitlemultiple loationsdocument owneremail addressrevision datehas a reminder email been sentday differencedate1date2link
EXTFormv1.0Form AyJ Bloggsjbloggs@test.com
23/02/2022​
would insert link into here
INTpolicyv1.0Policy ByJohn Doejdoe@test.com
23/02/2022​
would insert link into here
EXTprocedurev1.0Procedure Cyjane Doejdoe1@test.com
23/02/2022​
would insert link into here
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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