메인 컨텐츠로 가기

이메일 본문에 하이퍼 링크를 사용하여 Excel에서 이메일을 보내는 방법은 무엇입니까?

Excel에서 VBA 코드로 이메일을 보내려고 시도한 적이 있습니까? 이메일을 보낼 때 이메일 본문에 하이퍼링크를 추가하는 방법은 무엇입니까? 이 기사는 이 문제를 해결하는 데 도움이 될 것입니다.

VBA 코드로 이메일 본문에 하이퍼 링크 삽입


VBA 코드로 이메일 본문에 하이퍼 링크 삽입

아래 VBA 코드는 Excel에서 이메일을 보내고 이메일 본문에 특정 하이퍼 링크를 삽입하는 데 도움이 될 수 있습니다. 다음과 같이하십시오.

1. 통합 문서를 시작하고 다른 + F11 키를 눌러 응용 프로그램 용 Microsoft Visual Basic 창.

2. 에서 응용 프로그램 용 Microsoft Visual Basic 창을 클릭합니다 끼워 넣다 > 기준 치수, 그런 다음 아래 VBA 코드를 모듈 편집기에 복사하십시오.

VBA 코드 : 이메일 본문에 하이퍼 링크 삽입

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

배송 시 요청 사항:

  • 본문 내용과 하이퍼 링크를 변경하십시오. xStrBody 줄입니다.
  • 교체 "이메일 주소" 안에 하죠., .DC 그리고.BCC 이메일을 보낼 실제 이메일 주소가있는 줄. CC 및 BCC 줄이 필요하지 않은 경우 전체 코드에서 해당 줄을 제거하거나 줄 앞에 작은 따옴표를 추가하십시오. 'CC =”이메일 주소”.
  • 교체 "제목" 안에 .제목 귀하의 이메일 제목과 일치하십시오.

3. 누르세요 F5 코드를 실행하는 키입니다. 그런 다음 내부에 하이퍼 링크가 나열된 특정 필드와 본문으로 이메일이 생성됩니다. 보내기 버튼을 클릭하여 보냅니다.


관련 기사

Excel의 셀 값에 따라 자동으로 이메일 보내기
Excel에서 지정된 셀 값을 기반으로 Outlook을 통해 특정 수신자에게 이메일을 보내려고한다고 가정합니다. 예를 들어 워크 시트의 D7 셀 값이 200보다 크면 전자 메일이 자동으로 생성됩니다. 이 기사에서는이 문제를 빠르게 해결할 수있는 VBA 방법을 소개합니다.

Excel에서 버튼을 클릭하면 이메일 보내기
Excel 워크 시트에서 버튼을 클릭하여 Outlook을 통해 이메일을 보내야한다고 가정하면 어떻게 할 수 있습니까? 이 기사에서는 VBA 방법을 자세히 소개합니다.

Excel에서 기한이 충족되면 전자 메일 보내기
C 열의 기한이 7 일 (현재 날짜는 2017/9/13)보다 작거나 같다고 가정하고 B 열에 지정된 내용과 함께 A 열의 지정된 수신자에게 이메일 알림을 보냅니다. 어떻게 달성합니까? 이 기사의 방법이 도움이 될 수 있습니다.

최고의 사무 생산성 도구

🤖 Kutools AI 보좌관: 다음을 기반으로 데이터 분석을 혁신합니다. 지능형 실행   |  코드 생성  |  사용자 정의 수식 만들기  |  데이터 분석 및 차트 생성  |  Kutools 기능 호출...
인기 기능: 중복 항목 찾기, 강조 표시 또는 식별   |  빈 행 삭제   |  데이터 손실 없이 열이나 셀 결합   |   수식없이 반올림 ...
슈퍼 조회: 다중 기준 VLookup    다중 값 VLookup  |   여러 시트에 걸친 VLookup   |   퍼지 조회 ....
고급 드롭다운 목록: 드롭다운 목록을 빠르게 생성   |  종속 드롭다운 목록   |  다중 선택 드롭 다운 목록 ....
열 관리자: 특정 개수의 열 추가  |  열 이동  |  Toggle 숨겨진 열의 가시성 상태  |  범위 및 열 비교 ...
특색 지어진 특징: 그리드 포커스   |  디자인보기   |   큰 수식 바    통합 문서 및 시트 관리자   |  리소스 라이브러리 (자동 텍스트)   |  날짜 선택기   |  워크 시트 결합   |  셀 암호화/해독    목록으로 이메일 보내기   |  슈퍼 필터   |   특수 필터 (굵게/기울임꼴/취소선 필터링...) ...
상위 15개 도구 세트12 본문 도구 (텍스트 추가, 문자 제거,...)   |   50+ 거래차트 유형 (Gantt 차트,...)   |   40+ 실용 방식 (생일을 기준으로 나이 계산,...)   |   19 삽입 도구 (QR 코드 삽입, 경로에서 그림 삽입,...)   |   12 매출 상승 도구 (숫자를 단어로, 환율,...)   |   7 병합 및 분할 도구 (고급 결합 행, 셀 분할,...)   |   ... 그리고 더

Excel용 Kutools로 Excel 기술을 강화하고 이전과는 전혀 다른 효율성을 경험해 보세요. Excel용 Kutools는 생산성을 높이고 시간을 절약하기 위해 300개 이상의 고급 기능을 제공합니다.  가장 필요한 기능을 얻으려면 여기를 클릭하십시오...

상품 설명


Office Tab은 Office에 탭 인터페이스를 제공하여 작업을 훨씬 쉽게 만듭니다.

  • Word, Excel, PowerPoint에서 탭 편집 및 읽기 사용, Publisher, Access, Visio 및 Project.
  • 새 창이 아닌 동일한 창의 새 탭에서 여러 문서를 열고 만듭니다.
  • 생산성을 50% 높이고 매일 수백 번의 마우스 클릭을 줄입니다!
Comments (17)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hallo, das läuft soweit sehr gut.
Ich möchte jedoch, das ein Link generiert wird zu der Datei mit dem Dateinamen der aktuell geöffneten Datei. ThisWorkbook.FullName oder so ähnlich.
Wie würde der Code dann aussehen???

Vielen Dank
This comment was minimized by the moderator on the site
Does anyone know how to combine/ add this with a code I am already using to send an email? The one bellow?

Public Sub CheckAndSendMail()
'Updated by Extendoffice 2018/11/22
Dim xRgDate As Range
Dim xRgSend As Range
Dim xRgText As Range
Dim xRgDone As Range
Dim xOutApp As Object
Dim xMailItem As Object
Dim xLastRow As Long
Dim vbCrLf As String
Dim xMailBody As String
Dim xRgDateVal As String
Dim xRgSendVal As String
Dim xMailSubject As String
Dim i As Long
On Error Resume Next
Set xRgDate = Application.InputBox("Please select the due date column:", "KuTools For Excel", , , , , , 8)
If xRgDate Is Nothing Then Exit Sub
Set xRgSend = Application.InputBox("Please select the recipients?email column:", "KuTools For Excel", , , , , , 8)
If xRgSend Is Nothing Then Exit Sub
Set xRgText = Application.InputBox("Select the column with reminded content in your email:", "KuTools For Excel", , , , , , 8)
If xRgText Is Nothing Then Exit Sub
xLastRow = xRgDate.Rows.count
Set xRgDate = xRgDate(1)
Set xRgSend = xRgSend(1)
Set xRgText = xRgText(1)
Set xOutApp = CreateObject("Outlook.Application")
For i = 1 To xLastRow
xRgDateVal = ""
xRgDateVal = xRgDate.Offset(i - 1).Value
If xRgDateVal <> "" Then
If CDate(xRgDateVal) - Date <= 7 And CDate(xRgDateVal) - Date > 0 Then
xRgSendVal = xRgSend.Offset(i - 1).Value
xMailSubject = xRgText.Offset(i - 1).Value & " on " & xRgDateVal
vbCrLf = "<br><br>"
xMailBody = "<HTML><BODY>"
xMailBody = xMailBody & "Dear " & xRgSendVal & vbCrLf
xMailBody = xMailBody & "Text : " & xRgText.Offset(i - 1).Value & vbCrLf
xMailBody = xMailBody & "</BODY></HTML>"
Set xMailItem = xOutApp.CreateItem(0)
With xMailItem
.Subject = xMailSubject
.To = xRgSendVal
.HTMLBody = xMailBody
.Display
'.Send
End With
Set xMailItem = Nothing
End If
End If
Next
Set xOutApp = Nothing
End Sub
This comment was minimized by the moderator on the site
Hi Crystal, no problem, thank you anyway.
This comment was minimized by the moderator on the site
Hallo,

wie würde der Code aussehen, wenn im Email-Text genau der Link zu der Datei stehen soll, aus der heraus die Email generiert wurde? Nach dem Motto: "Gehe zu Datei xxx (als Link) und trage dort etwas ein.

Vielen Dank und schöne Grüße
Florian
This comment was minimized by the moderator on the site
Hi Florian Mußler,
Please change the following lines
 xStrBody = "Hi there:" & "<br>" _
              & "Please click " & "<a href="/ & "http://www.extendoffice.com"">Here</a> to open the page" & "<br>" _
              & "Thank you."

to
 xStrBody = "Hi there:" & "<br>" _
              & "Go to the file " & "<a href="/ & "I:\Work\Crystal\2023\Sales Report.xlsx"">Sales Report</a> and enter the content there" & "<br>" _
              & "Thank you."

where "I:\Work\Crystal\2023\Sales Report.xlsx" is the path of the file.
This comment was minimized by the moderator on the site
Thank you for your help. This already works great. Do you know how to write the code, if I have to extract the file address out of a cell?
This comment was minimized by the moderator on the site
Hi crystal,

thank you very much for your reply. This is what I came up with at first. The thing is, that the file we are talking about is based on a template. That means, that the file name is changed to an individual file name, that is always different. So the file name (link) in the code should be a variable, always leading to this exacte file (in which the code is running).

I hope I could describe this correctly, so you understand.

Thank you.
This comment was minimized by the moderator on the site
Hi Florian,

I understand what you mean now. But I'm sorry I don't know how to create a hyperlink to a workbook that contains a variable name.
This comment was minimized by the moderator on the site
Bonjour,
Merci pour cette procédure.
Comment puis-je remplacer le lien (qui est fixe) par un lien variable ?
...
Dim xStrBody As String
Dim Lien As String
Lien = "https://www.cyclodetente.be/"

xStrBody = "Hi there:" & "<br>" _
& "Please click " & "<a href="/ & "http://www.extendoffice.com"">Here</a> to open the page" & "<br>" _
& "Thank you."
...
Donc, remplacer "http://www.extendoffice.com" par la variable "Lien"

Un tout grand merci pour le retour,
This comment was minimized by the moderator on the site
Hi Christian,

Sorry I don't quite understand what you mean. For clarity, please attach a sample file or a screenshot with your data and desired results.
This comment was minimized by the moderator on the site
my link isn't clickable and I'm not sure why.

"Please Print <a href="/"http://codes" & Range("JobNumber") & "&ReportId=1"">" & "PhoneCodes</a>"

The link appears but I have to right-click on the email for it to open up. Any suggestions? Also, I don't really know much about VBA. This is something new I'm learning on my own.
This comment was minimized by the moderator on the site
Hi Maryanne,
By default, when you composing an email, hyperlinks are opened by clicking with pressing or holding the Ctrl key.
If you want to open a hyperlink with one click only, please turn off this function as follows.
1. In your Outlook, click File > Options.
2. In the Outlook Options dialog box, click Mail in the left pane, and then click the Editor Options button in the Compose Messages section;
3. In the Editor Options dialog box, click Advanced in the left pane, and then uncheck the Use CTRL + Click to follow hyperlink checkbox. See screenshot:
https://www.extendoffice.com/images/stories/comments/comment-picture-zxm/hyperlink.png
This comment was minimized by the moderator on the site
please i need help it doesnt work when the link have spaces in itfor ex file path MsgBox "C:\Users\Desktop\fs caché\Fusion fichier\TENDERING.xlsm"
xstrbody = "Request for an approval, <br> You can access to the file from " & "<a href= " & link & ">here</a>"
the link will be in this case : C:\Users\Desktop\fsany idea?
This comment was minimized by the moderator on the site
You can use: xstrbody = "Request for an approval, <br> You can access to the file from " & "<a href="/"" & link & """> here</a >"
This comment was minimized by the moderator on the site
this code is great, but how to send the current excel sheet in the email?
This comment was minimized by the moderator on the site
you use "xStrBody" part in your existing code, other search Excel to outlook email code online and use "xStrBody" this part.
This comment was minimized by the moderator on the site
you can use "xStrBody" part in other email code, which you are using now. otherwise search "excel to outlook email code".
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations