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

كيف ترسل بريدًا إلكترونيًا مرفقًا بعدة مرفقات في Excel؟

تتحدث هذه المقالة عن إرسال بريد إلكتروني من خلال Outlook مع مرفقات متعددة مرفقة في Excel.

أرسل بريدًا إلكترونيًا يحتوي على مرفقات متعددة مرفقة في Excel برمز VBA


أرسل بريدًا إلكترونيًا يحتوي على مرفقات متعددة مرفقة في Excel برمز VBA

يرجى القيام بما يلي لإرسال بريد إلكتروني مرفق به عدة مرفقات في Excel.

1. الرجاء إدخال زر الأمر بالنقر فوق المطور > إدراج > زر الأمر (عنصر تحكم ActiveX). انظر لقطة الشاشة:

2. بعد إدخال زر الأمر ، يرجى النقر بزر الماوس الأيمن فوقه وتحديده عرض الرمز من قائمة السياق.

3. في الافتتاح ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، الرجاء الضغط الأدوات > مراجع حسابات كما هو موضح أدناه لقطة الشاشة.

4. في ال المراجع - VBAProject مربع الحوار ، يرجى البحث والتحقق من مكتبة كائنات Microsoft Outlook الخيار ، ثم انقر فوق OK .

5. ثم استبدل الكود الأصلي في نافذة التعليمات البرمجية برمز VBA أدناه.

كود فبا: أرسل بريدًا إلكترونيًا مرفقًا بمرفقات متعددة في إكسيل

Private Sub CommandButton1_Click()
    Dim xStrFile As String
    Dim xFilePath As String
    Dim xFileDlg As FileDialog
    Dim xFileDlgItem As Variant
    Dim xOutApp As Outlook.Application
    Dim xMailOut As Outlook.MailItem
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    Set xFileDlg = Application.FileDialog(msoFileDialogFilePicker)
    If xFileDlg.Show = -1 Then
        With xMailOut
            .BodyFormat = olFormatRichText
            .To = ""
            .Subject = "test"
            .HTMLBody = "test"
            For Each xFileDlgItem In xFileDlg.SelectedItems
                .Attachments.Add xFileDlgItem
            Next xFileDlgItem
            .Display
        End With
    End If
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub

ملاحظات: يرجى تحديد مستلم البريد الإلكتروني والموضوع والجسم عن طريق تغيير المتغير في إلى = , .Subject = "اختبار" و .HTMLBody = "اختبار" خطوط في الكود.

6. اضغط على قديم + Q مفاتيح معًا للخروج من ميكروسوفت فيسوال باسيك للتطبيقات نافذة.

7. انقر المطور > وضع التصميم لإيقاف وضع التصميم. انظر لقطة الشاشة:

8. انقر فوق زر الأمر لتشغيل التعليمات البرمجية. في ظهرت تصفح نافذة ، حدد الملفات التي تريد إرفاقها في البريد الإلكتروني ، ثم انقر فوق OK زر. انظر لقطة الشاشة:

9. ثم يتم إنشاء بريد إلكتروني مع الحقول المحددة والمرفقات المدرجة. الرجاء النقر فوق أرسل زر لإرساله. انظر لقطة الشاشة:

ملاحظات: يعمل رمز VBA فقط عند استخدام Outlook كبرنامج بريد إلكتروني.


أرسل بريدًا إلكترونيًا بسهولة عبر Outlook استنادًا إلى حقول القائمة البريدية التي تم إنشاؤها في Excel:

إرسال رسائل البريد الإلكتروني فائدة كوتولس ل إكسيل يساعد المستخدمين على إرسال البريد الإلكتروني عبر Outlook بناءً على قائمة بريدية تم إنشاؤها في Excel.
قم بتنزيله وجربه الآن! (مسار مجاني لمدة 30 يومًا)



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

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

🤖 مساعد 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 (14)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
أريد إرسال بريد إلكتروني مع البريد أو hotmail مع CDO ولكن كل ما لدي فقط مع مرفق واحد ولكن أريد أن أرسل مع العديد من المرفقات يرجى إرسال لي عن طريق بريدي الإلكتروني الرمز أو ملف Excel
Rated 5 out of 5
This comment was minimized by the moderator on the site
Is het ook mogelijk om een filter te zetten op de selectie van de bijlagen, zodat er alleen pdf-bestanden aan de mail kunnen worden toegevoegd?
This comment was minimized by the moderator on the site
Hi Alex de Graaf,
The code directly calls the Microsoft's file selection window. This makes it easy for VBA users to select needed files.
This comment was minimized by the moderator on the site
Hi Crystal,
Yes, I do understand that. However, is it possible to restrict users to only select pdf-files?
This comment was minimized by the moderator on the site
Hi Crystal,

Yes, I understand that. However I want the users to only be able to select pdf-files.
Is this possible?
This comment was minimized by the moderator on the site
Hi Alex de Graaf,
The following VBA code lists only the PDF files in the Browse window. Please give it a try.

Private Sub CommandButton1_Click()
'Updated by Extendoffice 20220714
    Dim xStrFile As String
    Dim xFilePath As String
    Dim xFileDlg As FileDialog
    Dim xFileDlgItem As Variant
    Dim xOutApp As Outlook.Application
    Dim xMailOut As Outlook.MailItem
    Application.ScreenUpdating = False
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    Set xFileDlg = Application.FileDialog(msoFileDialogFilePicker)
    xFileDlg.Filters.Add "PDF", "*.pdf", 1
xFileDlg.FilterIndex = 1
    If xFileDlg.Show = -1 Then
        With xMailOut
            .BodyFormat = olFormatRichText
            .To = ""
            .Subject = "test"
            .HTMLBody = "test"
            For Each xFileDlgItem In xFileDlg.SelectedItems
                .Attachments.Add xFileDlgItem
            Next xFileDlgItem
            .Display
        End With
    End If
    Set xMailOut = Nothing
    Set xOutApp = Nothing
    Application.ScreenUpdating = True
End Sub
This comment was minimized by the moderator on the site
Hola,
Me gustaría saber como quedaría la macro si quisiera enviar en un mismo correo a varias personas o más y con varios ficheros o más.
Muchas gracias.
This comment was minimized by the moderator on the site
I have enjoyed working through this solution for adding multiple attachments to an email from within Excel VBA. Thank you. I know that a lot of us benefit and then want some aspect customized for exactly what we are trying to do. I am no different, but for step 8. Can we set the path that the Browse window will open with? I can browse over to another folder at a different location but if I could set the path that would be a time saver.
This comment was minimized by the moderator on the site
Superb...... Works perfectly.
This comment was minimized by the moderator on the site
HI Team ....i am unable to see the attachment in mail so if i follow the your step...can you pls help
This comment was minimized by the moderator on the site
the above code works perfectly thanks!! but my email automatic signature seem to disappear with this code. any idea why?
This comment was minimized by the moderator on the site
What if multiple different user and different attachment to be send with different subject line.
This comment was minimized by the moderator on the site
What if above files are located in sub-folders? How to look for a file in folder and sub-folders?
This comment was minimized by the moderator on the site
I am able to "Quickly send email with multiple attachments attached in Excel with Kutools for Excel" using your steps above, but would like to take it one step further and personalize each email by inserting their names (from a column in the Excel sheet) into the body of the email. While in the body of the email, I try selecting the field and clicking on "Insert Placeholder" but nothing happens. Any idea why or how I can fix this? Thank you!
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations