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

كيفية إرسال تذكير أو إعلام بالبريد الإلكتروني إذا تم تحديث المصنف في Excel؟

في بعض الحالات ، قد تحتاج إلى تشغيل إعلام بالبريد الإلكتروني إلى مستلم محدد إذا كانت هناك بيانات محدثة في المصنف الذي أرسلته. ستوضح لك هذه المقالة طريقة تحقيق ذلك.

إرسال تذكير بالبريد الإلكتروني أو إعلام إذا تم تحديث المصنف برمز VBA


إرسال تذكير بالبريد الإلكتروني أو إعلام إذا تم تحديث المصنف برمز VBA

يرجى القيام بما يلي لإرسال تذكير أو إعلام بالبريد الإلكتروني إذا تم تحديث المصنف.

1. في المصنف ، افتح ورقة عمل محددة سترسل إشعارًا بالبريد الإلكتروني بناءً على البيانات المحدثة بالداخل.

2. انقر بزر الماوس الأيمن فوق علامة تبويب الورقة ، وحدد عرض الرمز من قائمة النقر بزر الماوس الأيمن. انظر لقطة الشاشة:

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات نافذة ، انسخ والصق الكود التالي في نافذة الكود. انظر لقطة الشاشة:

رمز فبا: إرسال تذكير أو إعلام بالبريد الإلكتروني إذا تم تحديث المصنف

Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 2017/9/14
    Dim xOutApp As Object
    Dim xMailItem As Object
    Dim xName As String
    Dim xYesOrNo As Integer
    On Error Resume Next
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailItem = xOutApp.CreateItem(0)
    xYesOrNo = MsgBox("Want to attach updated workbook in email?", vbInformation + vbYesNo, "KuTools For Excel")
    If xYesOrNo = 6 Then ActiveWorkbook.Save
    If xYesOrNo = 6 Then xName = ActiveWorkbook.FullName
    With xMailItem
        .To = "Email Address"
        .cc = ""
        .Subject = "email notification test"
        .Body = "Hi," & Chr(13) & Chr(13) & "File is now updated."
        If xYesOrNo = 6 Then .Attachments.Add xName
        .Display
    End With
    xMailItem = Nothing
    xOutApp = Nothing
End Sub

ملاحظات: استبدل عنوان البريد الإلكتروني بعنوان البريد الإلكتروني للمستلم في السطر .To = "عنوان البريد الإلكتروني". وقم بتغيير حقول Cc والموضوع وكذلك الجسم في كود VBA حسب حاجتك.

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

4. بعد تحرير خلية في ورقة العمل ، أ كوتولس ل إكسيل سيظهر مربع الحوار كما هو موضح أدناه. إذا كنت ترغب في إرفاق المصنف المحدث بالبريد الإلكتروني ، فيرجى النقر فوق نعم زر. إذا لم يكن كذلك ، فانقر فوق لا .

5. ثم يتم إنشاء بريد إلكتروني تلقائيًا مع إرفاق المصنف المحدث أو بدونه. وجميع الحقول المحددة مدرجة أيضًا في البريد الإلكتروني. الرجاء الضغط على أرسل زر لإرساله.

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


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

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

🤖 مساعد 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 (20)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
I am following certificates log in excel sheet. i need to get reminder before the certificates getting expired. please advice me.
This comment was minimized by the moderator on the site
Hi rahul rajan,

Do you want to pop up a reminder based on the date of a cell?
This comment was minimized by the moderator on the site
Hi which part of the code should i delete so it only sends email when i click save and not on every action ?
This comment was minimized by the moderator on the site
Hi donkeh,
In the VBA code, please replace the following line:
.Display
with
.Send
This comment was minimized by the moderator on the site
HOLA CRISTAL, ME GUSTARIA PONERME EN CONTACTO DIRECTO CONTIGO, PARA PEDIR TU AYUDA EN UN PROBLEMITA EN UNA HOJA DE EXCEL
This comment was minimized by the moderator on the site
Hi GERARDO MARTIN OLVERA,
You can email me at .
This comment was minimized by the moderator on the site
HOLA CRISTAL, ME GUSTARIA PONERME EN CONTACTO DIRECTO CONTIGO, NE CESITO DE TU AYUDA EN EXCEL,GRACIAS
This comment was minimized by the moderator on the site
please i am a bit confused but where in the code does it detect the sheet being modified/updated?
i am trying to write a code where the table on a particular sheet gets sent when the table is modified (or more specifically when rows are added)
thank you!
This comment was minimized by the moderator on the site
Hi,
The code in the post detects all cells in the entire worksheet based on the first line of "Private Sub Worksheet_Change(ByVal Target As Range)".
If you want to send an email with a particular table when it is modified, you can try the following VBA.
Note: please change "Table1" to your own table name.
Private Sub Worksheet_Change(ByVal Target As Range)
'Updated by Extendoffice 2022/5/27
    Dim xYesOrNo As Integer
    Dim xTableName As String
    Dim xTableRg As Range
    Dim I, J As Long
    Dim xEmailBody As String
    Dim xMailOut As Object
    Dim xOutApp As Object
    On Error Resume Next
    
    xTableName = "Table1" 'The name of the table you will send when it is modified
    Set xTableRg = ActiveSheet.ListObjects(xTableName).Range
    If Intersect(Target, xTableRg) Is Nothing Then Exit Sub

    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailOut = xOutApp.CreateItem(olMailItem)
    For I = 1 To xTableRg.Rows.Count
        For J = 1 To xTableRg.Columns.Count
            xEmailBody = xEmailBody & "  " & xTableRg.Cells(I, J).Value
        Next
        xEmailBody = xEmailBody & vbNewLine
    Next
    xEmailBody = "Hi" & vbLf & vbLf & " body of message you want to add" & vbLf & vbLf & xEmailBody & vbNewLine
    With xMailOut
        .Subject = "Test"
        .To = ""
        .Body = xEmailBody
        .Display
        '.Send
    End With
    Set xMailOut = Nothing
    Set xOutApp = Nothing
End Sub
This comment was minimized by the moderator on the site
Hola cristal, donde dice Private Sub Worksheet_Change, deberia poner el nombre de mi excel o no?
Los rangos de (I,J) cambiarlos por los valores de celdas que yo dese estar mirando si cambian?
This comment was minimized by the moderator on the site
For me the code runs again and again, its like never ending loop. I close email it asks again to send it...
This comment was minimized by the moderator on the site
When I tried to change something in a cell a message prompted for Outlook email configuration and it just keeps on asking for my password.
This comment was minimized by the moderator on the site
Hi MJ,
Which Excel version are you using? Can you provide a screenshot of the prompt?
This comment was minimized by the moderator on the site
Sorry, I posted this in the wrong article. I will post in the correct article
This comment was minimized by the moderator on the site
Hello there, The code works great. However, when a cell changes to below the threshold point via a macro operation that copies and pastes the lower value into the designated cell, the code doesn't seem to trigger.

Also, I would like to apply this code to several cells. Can I copy and paste the code several times and change each copied version to fit each cells' needs? Is there a better way to do that. I can't figure that out. Thank you!
This comment was minimized by the moderator on the site
I copied and pasted the code exactly as-is from this page, but when I make a change to my document I get the message "Syntax Error" and this line highlights: Dim xOutApp As Object. Any help would be appreciated.
This comment was minimized by the moderator on the site
Hi Judy,
Would you provide the Excel version you are using? Thank you for your comment.
There are no comments posted here yet
Load More
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations