انتقل إلى المحتوى الرئيسي

كيفية إرسال بريد إلكتروني من Excel مع ارتباط تشعبي في نص البريد الإلكتروني؟

هل سبق لك أن حاولت إرسال بريد إلكتروني برمز VBA في Excel؟ وكيف تضيف ارتباطات تشعبية إلى نص البريد الإلكتروني عند إرسال بريد إلكتروني؟ هذه المقالة سوف تساعد في حل هذه المشكلة.

قم بإدراج ارتباط تشعبي في نص البريد الإلكتروني باستخدام رمز VBA


قم بإدراج ارتباط تشعبي في نص البريد الإلكتروني باستخدام رمز VBA

يمكن أن يساعد رمز VBA أدناه في إرسال بريد إلكتروني من Excel وإدراج ارتباط تشعبي محدد في نص البريد الإلكتروني. الرجاء القيام بما يلي.

1. قم بتشغيل المصنف الخاص بك ، اضغط على قديم + F11 مفاتيح لفتح ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات الإطار، انقر فوق إدراج > وحدة، ثم انسخ رمز 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 الخط.
  • استبدل "البريد الإلكتروني"في . ول, .نسخة و.BCC تحتوي على عناوين البريد الإلكتروني الفعلية التي سترسل إليها بريدًا إلكترونيًا. إذا لم تكن بحاجة إلى سطور CC و BCC ، فما عليك سوى إزالتها من الكود بالكامل ، أو إضافة اقتباس واحد قبل السطور ، مثل "CC =" عنوان البريد الإلكتروني ".
  • استبدل "سطر الموضوع"في .موضوع تتماشى مع موضوع البريد الإلكتروني الخاص بك.

3. اضغط على F5 مفتاح لتشغيل الكود. ثم يتم إنشاء البريد الإلكتروني مع الحقول المحددة والجسم مع وجود ارتباط تشعبي مدرج بالداخل ، انقر فوق الزر إرسال لإرساله.


مقالات ذات صلة

إرسال البريد الإلكتروني تلقائيًا بناءً على قيمة الخلية في Excel
لنفترض أنك تريد إرسال بريد إلكتروني عبر Outlook إلى مستلم معين بناءً على قيمة خلية محددة في Excel. على سبيل المثال ، عندما تكون قيمة الخلية D7 في ورقة العمل أكبر من 200 ، يتم إنشاء بريد إلكتروني تلقائيًا. تقدم هذه المقالة طريقة VBA لك لحل هذه المشكلة بسرعة.

أرسل بريدًا إلكترونيًا إذا تم النقر فوق الزر في Excel
لنفترض أنك بحاجة إلى إرسال بريد إلكتروني من خلال Outlook بالنقر فوق زر في ورقة عمل Excel ، كيف يمكنك القيام بذلك؟ ستقدم هذه المقالة طريقة VBA لتحقيق ذلك بالتفصيل.

أرسل بريدًا إلكترونيًا إذا تم الوفاء بتاريخ الاستحقاق في Excel
لنفترض أن تاريخ الاستحقاق في العمود C أقل من أو يساوي 7 أيام (التاريخ الحالي هو 2017/9/13) ، ثم أرسل تذكيرًا بالبريد الإلكتروني إلى المستلم المحدد في العمود A بمحتوى محدد في العمود B. كيف يتم تحقيق ذلك؟ الطريقة في هذه المقالة يمكن أن تقدم لك معروفًا.

أفضل أدوات إنتاجية المكتب

🤖 مساعد Kutools AI: إحداث ثورة في تحليل البيانات على أساس: التنفيذ الذكي   |  إنشاء التعليمات البرمجية  |  إنشاء صيغ مخصصة  |  تحليل البيانات وإنشاء الرسوم البيانية  |  استدعاء وظائف Kutools...
الميزات الشعبية: البحث عن التكرارات أو تمييزها أو تحديدها   |  حذف الصفوف الفارغة   |  دمج الأعمدة أو الخلايا دون فقدان البيانات   |   جولة بدون صيغة 
سوبر بحث: معايير متعددة VLookup    VLookup ذات القيمة المتعددة  |   VLookup عبر أوراق متعددة   |   بحث غامض ....
قائمة منسدلة متقدمة: إنشاء القائمة المنسدلة بسرعة   |  القائمة المنسدلة التابعة   |  قائمة منسدلة متعددة التحديد ....
مدير العمود: إضافة عدد محدد من الأعمدة  |  نقل الأعمدة  |  تبديل حالة رؤية الأعمدة المخفية  |  مقارنة النطاقات والأعمدة 
الميزات المميزة: التركيز على الشبكة   |  عرض تصميم   |   شريط الفورمولا الكبير    مدير المصنفات والأوراق   |  مكتبة الموارد (النص السيارات)   |  منتقي التاريخ   |  اجمع أوراق العمل   |  تشفير/فك تشفير الخلايا    إرسال رسائل البريد الإلكتروني عن طريق القائمة   |  سوبر تصفية   |   مرشح خاص (تصفية غامق / مائل / يتوسطه خط ...) ...
أفضل 15 مجموعة أدوات12 نص الأدوات (إضافة نص, إزالة الأحرف، ...)   |   +50 رسم الأنواع (مخطط جانت، ...)   |   40+ عملي الصيغ (احسب العمر على أساس تاريخ الميلاد، ...)   |   19 إدخال الأدوات (أدخل رمز الاستجابة السريعة, إدراج صورة من المسار، ...)   |   12 تحويل الأدوات (أرقام إلى كلمات, نتيجة تحويل عملة، ...)   |   7 دمج وتقسيم الأدوات (الجمع بين الصفوف المتقدمة, تقسيم الخلايا، ...)   |   ... و اكثر

عزز مهاراتك في Excel باستخدام Kutools for Excel، واختبر كفاءة لم يسبق لها مثيل. يقدم Kutools for Excel أكثر من 300 ميزة متقدمة لتعزيز الإنتاجية وتوفير الوقت.  انقر هنا للحصول على الميزة التي تحتاجها أكثر...

الوصف


يجلب Office Tab الواجهة المبوبة إلى Office ، ويجعل عملك أسهل بكثير

  • تمكين التحرير والقراءة المبوبة في Word و Excel و PowerPointوالناشر والوصول و Visio والمشروع.
  • فتح وإنشاء مستندات متعددة في علامات تبويب جديدة من نفس النافذة ، بدلاً من النوافذ الجديدة.
  • يزيد من إنتاجيتك بنسبة 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