Excel VBA to send email. Message cut off

Verstegen99

New Member
Joined
Apr 24, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

For my work I have to send out multiple simmilar emails with a few minor changes per email towards cliënts.

I am making (or trying) to make tool that prepares the emails for me as a whole (receiver, header, body).
I would only have to click a hyperlink, check if everything is correct and send it.

I managed to create a hyperlink containing 1336 characters. But when I add a relatively basic additional cell reference it won't work anymore (no link is generated).
I think it is because there are too many characters in the email (extending the name in the greeting also "breaks" the link).

Does anyone know of a good alternative?

My current code is;

Private Sub Worksheet_Change(ByVal Target As Range)
Dim h As Hyperlink, r As Range, c As Range, n As Long

Set r = Intersect(Target, Range("B2:E" & Cells(Rows.Count, "B").End(xlUp).Row))
If r Is Nothing Then Exit Sub

Application.EnableEvents = False

On Error Resume Next
For Each c In r.Rows
n = c.Row
Set r = Cells(n, "G")
With r
.Hyperlinks(1).Delete
'"mailto:"&B&"?Subject="&N&"&Body="&O&C&P&Q
.Hyperlinks.Add r, "mailto:" & Cells(n, "B") & "?Subject=" & Cells(n, "N") & "&Body=" & _
Cells(n, "O") & Cells(n, "C") & Cells(n, "P") & Cells(n, "Q"), , , "Click Here"
End With
Next c

Application.EnableEvents = True
End Sub

Thanks in advance.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I've never used that method - usually used Automation (it may have a different name now) because it's much more powerful. Basically, you interact with outlook to create/send email from Access, Excel and the like. If you research the method you'll find a gazillion code examples and one or more of them will probably be useful to you. If you're not using Outlook then that is a different matter.

EDIT forgot to say please enclose code in code tags (vba button on posting toolbar) to maintain indentation and readability.
 
Upvote 0

Forum statistics

Threads
1,224,815
Messages
6,181,135
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