- To post as a guest, your comment is unpublished.· 3 months agoyou use "xStrBody" part in your existing code, other search Excel to outlook email code online and use "xStrBody" this part.
- To post as a guest, your comment is unpublished.· 3 months agoyou can use "xStrBody" part in other email code, which you are using now. otherwise search "excel to outlook email code".
How to send email from Excel with hyperlink in the email body?
Have you ever tried to send email with VBA code in Excel? And how to add hyperlinks to the email body text when sending email? This article will help to solve this problem.
The below VBA code can help to send email from Excel and insert specific hyperlink in the email body. Please do as follows.
1. Launch your workbook, press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module, and then copy the below VBA code into the Module editor.
VBA code: Insert hyperlink into email body
Sub EmailHyperlink() 'updated by Extendoffice 20190815 Dim xOtl As Object Dim xOtlMail As Object Dim xStrBody As String xStrBody = "Hi there：" & "<br>" _ & "Please click " & "<a href="/"http://www.extendoffice.com"">Here</a> to open the page" & "<br>" _ & "Thank you." On Error Resume Next Set xOtl = CreateObject("Outlook.Application") Set xOtlMail = xOtl.CreateItem(olMailItem) With xOtlMail .To = "Email Address" .CC = "Email Address " .BCC = " Email Address " .Subject = "Subject line" .HTMLBody = .HTMLBody & xStrBody .Display End With Set xOtl = Nothing Set xOtlMail = Nothing End Sub
- Please change the body content and the hyperlink in the xStrBody line.
- Replace the “Email Address” in the .To, .CC and .BCC lines with the actual email addresses you will send email to. If you don’t need the CC and BCC lines, just remove them from the whole code, or add a single quote before the lines, such as 'CC =”Email Address”.
- Replace the “Subject line” in the .Subject line with your email subject own.
3. Press the F5 key to run the code. Then the email is created with specified fields and body with hyperlink listed inside, click the Send button to send it.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
- To post as a guest, your comment is unpublished.· 6 months agothis code is great, but how to send the current excel sheet in the email?