VBA FollowHyperlink Generating Email Template Without Subject/Body Character Limit

whereswaller

New Member
Joined
Aug 27, 2013
Messages
12
Hi,
I am trying to insert a button into my Excel spreadsheet that pulls the contents from neighbouring cells and inserts them into an email (which would become a template). The below code works in most instances, however when the characters in the mailto string exceed ~900 characters I receive the following error, "Run-time error '5': Invalid procedure call or argument". How do I get around this?

Code:
Sub emailer()


Dim r As String, i As String, e As String, x As Long, y As Long, s As String, b As String, mailto As String


r = ActiveSheet.Shapes(Application.Caller).TopLeftCell.Row


i = Range("H" & r)
x = InStr(i, "(")
y = InStrRev(i, ")")
e = Mid(i, x + 1, y - x - 1)


s = Range("D" & r)


b = Replace(Range("E" & r), "]", "]%0D%0A")
If ActiveWorkbook.Worksheets("Task List").Range("C6") <> Empty Then
    b = Replace(b, "RM/AE Name: [insert]", "RM/AE Name: " & ActiveWorkbook.Worksheets("Task List").Range("C6"))
End If
If ActiveWorkbook.Worksheets("Task List").Range("C7") <> Empty Then
    b = Replace(b, "State: [insert]", "State: " & ActiveWorkbook.Worksheets("Task List").Range("C7"))
End If
If ActiveWorkbook.Worksheets("Task List").Range("C8") <> Empty Then
    b = Replace(b, "Tier: [insert]", "Tier: " & ActiveWorkbook.Worksheets("Task List").Range("C8"))
End If
b = Replace(b, "I accept", "%0D%0AI accept")


mailto = "mailto:" & e & "?subject=" & s & "&body=" & b


ActiveWorkbook.FollowHyperlink mailto


End Sub

Many thanks in advance,
James
 
Hi Jerry,
Thanks for your suggestion. I have already been on Ron de Bruin's website and, unfortunately, the functionality he demonstrates is not what I'm looking for.

Essentially, all I would like to do is launch the "create e-mail" prompt on the user's default "mailto:" program and populate the To, Subject and Body fields with some pre-defined text. I do not want the e-mail to send and I want the populating text to be unlimited in length.

My existing code does all of the above except allow me to populate text to an unlimited length.

Thoughts?
James
 
Upvote 0

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