Add Variable into Mailto Hyperlink Subject

Sinder

New Member
Joined
Jul 22, 2015
Messages
1
Hi

I'm strugglig work with a Mailto hyperlink code. My code functions as follows:

  • a FOR loop will run ror every row in my sheet called "DATA"
  • For every row and email will generate with certain details
    • On this email there are two Mailto links available to either "confirm" or "not confirm"
    • If the user clicks "Confirm" or "Not Confirm" a new email message will display.

What i need is, in this new email, the subject line should include the trade number which is a variable i declared initially in my code.

Below are the elements of my code. The items in red is what i am struggling to figure out. As i mentioned i am trying to include in the subject the "StrTradeNo".

Dim StrTradeNo As String
StrTradeNo = Sheets("Data").Cells(lCounter, 10)

TempFileName = "Settlement Confirmation: " & StrTradeType & " - " & StrCounter & " - " & StrValueDate & " TradeID: " & StrTradeNo

Set rng = Nothing
On Error Resume Next
'Only the visible cells in the selection
'Set rng = Selection.SpecialCells(xlCellTypeVisible)
'You can also use a fixed range if you want
Set rng = Sheets("Data").Range(Cells(lCounter, 3), Cells(lCounter, 7)).SpecialCells(xlCellTypeVisible)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "The selection is not a range or the sheet is protected" & _
vbNewLine & "please correct and try again.", vbOKOnly
Exit Sub
End If
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)


StrBody1 = "Dear Client" & "

" & _
"Please kindly confirm the below:" & "

"

StrBody2 = "Click here to reponse: < a href=' mailto: name surname< emial address >?Subject=Payment Confirmation: Confirmed' & StrTradeNo&'&Body=Please kindly proceed with payment.%0A%0AThank you.'> Confirmed" & "< /a >< br >"

StrBody3 = "Click here to reponse: < a href='mailto: name surname<
email address >?Subject=Payment Confirmation: Not Confirmed & Body=Please DO NOT proceed with payment.%0A%0AThank you. '> Not Confirmed" & "< /a >< br >< br >"

StrBody4 = "< br >< br >" & "Kind Regards" & "< br >" & _
"CIB Confirmation | Global Markets Operations | Standard Bank"

On Error GoTo Err_Email_not_Sent:
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = TempFileName
.HTMLBody = StrBody1 & RangetoHTML(rng) & "< br >" & StrBody2 & StrBody3 & StrBody4
'.Send 'or
.Display
End With
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,215,347
Messages
6,124,421
Members
449,157
Latest member
mytux

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