Excel Email and Hyperlinks

RhysPhelps

New Member
Joined
Mar 19, 2009
Messages
20
Bonjour all, this is quickly becoming my most favourite website :p

I have *ahem* created *ahem* with copious amounts of help from websites through google a macro that generates emails from an excel sheet. My sheet contains hyperlinks to documents that when i run the macro (thus opening an email) are not copied into the email (i.e they are just whatever text happens to be in the sheet.) is it possible to copy over hyperlinks?

the macro i am using is below. no doubt the very helpful person who created this would recognise it and i am in no way claiming it is mine. if you do happen to read this my thanks go out to you, you incredibly helpful hero.

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
Sub SendEMail()
Dim Email As String, Subj As String
Dim Msg As String, URL As String
Email = Cells(ActiveCell.Row, 3)

Subj = Cells(ActiveCell.Row, 15)
Msg = ""
Msg = Msg & "Dear " & Cells(ActiveCell.Row, 3) & "," & vbCrLf & vbCrLf & "The termination notice date of the contract number below is only 1 month away. Please contact the Budget Holder to find out if a Renewal is required or, in the case of an automatic renewal, whether the contract should continue. If this contract has been mistakenly assigned please contact who will make the appropriate changes" & vbCrLf & vbCrLf & Cells(ActiveCell.Row, 1) & vbCrLf & vbCrLf & "Many Thanks, Your friendly helpful excel sheet genie."

'Replace spaces with %20 (hex)
Subj = Application.WorksheetFunction.Substitute(Subj, " ", "%20")
Msg = Application.WorksheetFunction.Substitute(Msg, " ", "%20")

'Replace carriage returns with %0D%0A (hex)
Msg = Application.WorksheetFunction.Substitute(Msg, vbCrLf, "%0D%0A")

'Create the URL
URL = "mailto:" & Email & "?subject=" & Subj & "&body=" & Msg

'Execute the URL (start the email client)
ShellExecute 0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus

'Wait two seconds before sending keystrokes
'Application.Wait (Now + TimeValue("0:00:02"))
'Application.SendKeys "%s"
End Sub


The hyperlinks are contained in column A and refer to the bold part of the macro above

Thanks all
 

Some videos you may like

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.

Watch MrExcel Video

Forum statistics

Threads
1,123,307
Messages
5,600,869
Members
414,411
Latest member
Snowmanaus

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
Top