نصيحة: اللغات الأخرى مترجمة من قبل Google. يمكنك زيارة English نسخة من هذا الرابط.
تسجيل الدخول
x
or
x
x
التسجيل
x

or

كيفية إرسال البريد الإلكتروني إذا تم استيفاء تاريخ الاستحقاق في إكسيل؟

كما هو موضح أدناه في الصورة المعروضة، إذا كان تاريخ الاستحقاق في العمود C أقل من أو يساوي أيام شنومكس (التاريخ الحالي هو شنومكس / شنومكس / شنومكس)، ثم أرسل رسالة تذكير بالبريد الإلكتروني إلى المستلم المحدد في العمود A مع محتوى محدد في العمود B. كيفية تحقيق ذلك؟ سوف توفر هذه المقالة طريقة فبا للتعامل معها في التفاصيل.

إرسال البريد الإلكتروني إذا تم استيفاء تاريخ الاستحقاق مع التعليمات البرمجية فبا

علامة تبويب Office تمكين التحرير والتصفح في Tabbed ، وجعل عملك أسهل بكثير ...
Kutools for Excel يحل معظم مشاكلك ، ويزيد من إنتاجيتك بنسبة 80٪
  • إعادة استخدام أي شيء: أضف الصيغ الأكثر استخدامًا أو تعقيدًا والمخططات وأي شيء آخر إلى مفضلاتك ، ثم أعد استخدامها سريعًا في المستقبل.
  • أكثر من ميزات نص 20: استخراج الرقم من سلسلة النص ؛ استخراج أو إزالة جزء من النصوص ؛ تحويل الأرقام والعملات إلى الكلمات الإنجليزية ...
  • دمج الأدوات: العديد من المصنفات والأوراق في واحد ؛ دمج خلايا / صفوف / أعمدة متعددة دون فقدان البيانات ؛ دمج الصفوف المكررة ومجموع ...
  • أدوات الانقسام: تقسيم البيانات إلى أوراق متعددة بناءً على القيمة ؛ مصنف واحد إلى ملفات Excel أو PDF أو CSV متعددة ؛ عمود واحد إلى أعمدة متعددة ...
  • لصق الطفر الصفوف المخفية / المصفاة ؛ عدد ومبلغ بواسطة لون الخلفية. إنشاء قائمة بريدية و إرسال رسائل البريد الإلكتروني حسب قيمة الخلية...
  • فلتر سوبر: إنشاء مخططات تصفية متقدمة وتطبيقها على أي أوراق ؛ فرز حسب الأسبوع ، اليوم ، التردد وغير ذلك ؛ تصفية / فلترة بواسطة جريئة ، الصيغ ، التعليق ...
  • أكثر من ميزات 300 القوية ؛ يعمل مع Office 2007-2019 و 365 ؛ يدعم جميع اللغات ؛ سهولة النشر في مؤسستك أو مؤسستك.

إرسال البريد الإلكتروني إذا تم استيفاء تاريخ الاستحقاق مع التعليمات البرمجية فبا


يرجى القيام بما يلي لإرسال تذكير بالبريد الإلكتروني إذا تم استيفاء تاريخ الاستحقاق في إكسيل.

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

2. في ال ميكروسوفت فيسوال باسيك للتطبيقات نافذة، الرجاء النقر إدراج > وحدة. ثم انسخ والصق رمز فبا أدناه في إطار الوحدة النمطية.

رمز فبا: إرسال بريد إلكتروني إذا تم إغلاق تاريخ الاستحقاق في إكسيل

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

الملاحظات: الخط إذا كان كديت (زرغداتيفال) - التاريخ <= شنومكس و كديت (زرغداتيفال) - ديت> شنومكس ثم في التعليمات البرمجية فبا يعني أن تاريخ الاستحقاق يجب أن يكون أكبر من يوم شنوم وأقل من أو يساوي أيام شنومك. يمكنك تغييره كما تحتاج.

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

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

5. في الاخير كوتولس ل إكسيل مربع الحوار، حدد المحتوى الذي تريد عرضه في جسم البريد الإلكتروني، ثم انقر فوق OK .

ثم سيتم إنشاء بريد إلكتروني تلقائيا مع المستلم المحدد والموضوع والجسم المدرجة إذا كان تاريخ الاستحقاق في العمود C أقل من أو يساوي أيام شنومك. يرجى النقر فوق إرسال زر لإرسال البريد الإلكتروني.

الملاحظات:

1. كل البريد الإلكتروني الذي تم إنشاؤه يقابل تاريخ الاستحقاق. على سبيل المثال، إذا كان هناك ثلاثة تواريخ استحقاق تلبية المعايير، سيتم إنشاء ثلاث رسائل البريد الإلكتروني تلقائيا.

2. لن يتم تشغيل هذا الرمز إذا لم تكن هناك تواريخ تلبي المعايير.

3. تعمل التعليمات البرمجية فبا فقط عند استخدام أوتلوك كبرنامج البريد الإلكتروني الخاص بك.


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


Kutools for Excel يحل معظم مشاكلك ، ويزيد من إنتاجيتك بنسبة 80٪

  • إعادة استخدام: إدراج بسرعة الصيغ المعقدة ، الرسوم البيانية وأي شيء استخدمته من قبل ؛ تشفير الخلايا مع كلمة المرور إنشاء قائمة بريدية وإرسال رسائل البريد الإلكتروني ...
  • سوبر الفورمولا بار (بسهولة تحرير أسطر متعددة من النص والصيغة) ؛ تخطيط القراءة (بسهولة قراءة وتحرير أعداد كبيرة من الخلايا) ؛ لصق على المدى المصفى...
  • دمج الخلايا / الصفوف / الأعمدة دون فقدان البيانات ؛ انقسام خلايا المحتوى ؛ الجمع بين تكرار الصفوف / الأعمدة... منع الخلايا المكررة. مقارنة النطاقات...
  • حدد تكرار أو فريد الصفوف. حدد صفوف فارغة (جميع الخلايا فارغة) ؛ سوبر البحث والعثور غامض في العديد من المصنفات ؛ اختيار عشوائي ...
  • نسخة طبق الأصل خلايا متعددة دون تغيير مرجع الصيغة ؛ إنشاء المراجع تلقائيًا إلى أوراق متعددة. إدراج الرصاصات، مربعات الاختيار والمزيد ...
  • استخراج النص، إضافة نص ، حذف حسب الموضع ، إزالة الفضاء. إنشاء وطباعة مجاميع ترحيل الصفحات ؛ تحويل بين محتوى الخلايا والتعليقات...
  • سوبر تصفية (حفظ وتطبيق مخططات التصفية على أوراق أخرى) ؛ تصنيف متقدم حسب الشهر / الأسبوع / اليوم ، التردد وأكثر ؛ فلتر خاص بواسطة جريئة ، مائل ...
  • الجمع بين المصنفات وأوراق العمل. دمج الجداول على أساس الأعمدة الرئيسية ؛ تقسيم البيانات إلى أوراق متعددة; دفعة تحويل XLS ، XLSX وقوات الدفاع الشعبي...
  • أكثر من ميزات 300 القوية. يدعم Office / Excel 2007-2019 و 365. يدعم جميع اللغات. سهولة النشر في مؤسستك أو مؤسستك. ميزات كاملة النسخة التجريبية المجانية من 30.
علامة التبويب kte 201905

علامة تبويب Office توفر واجهة مبوبة لـ Office ، واجعل عملك أسهل بكثير

  • تمكين تحرير علامات التبويب والقراءة في Word و Excel و PowerPointوالناشر والوصول ، Visio ومشروع.
  • افتح مستندات متعددة وقم بإنشائها في علامات تبويب جديدة لنفس النافذة ، وليس في نوافذ جديدة.
  • يزيد إنتاجيتك بنسبة 50٪ ، ويقلل مئات نقرات الماوس لك كل يوم!
أسفل مكتبه
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Muru · 29 days ago
    I'm Beginner here, I have tried the given VBA code and its works well.
    can I stop triggering an email if the case is closed before meeting the due date?
  • To post as a guest, your comment is unpublished.
    Muru · 1 months ago
    hi
    I'm a beginner to VBA. I have tried the given format and its works well.

    Sometimes my clients meet earlier than my due date so in this situation how to stop the email triggering?

    Regards
    Muru
  • To post as a guest, your comment is unpublished.
    Tina · 1 months ago
    I am trying to use this code but when I run it, it just comes up with "Compile error: Invalid outside procedure". Do you think you could help please?
    Many thanks
    Tina
  • To post as a guest, your comment is unpublished.
    Mindie · 1 months ago
    I copied the VBA code you provided for this, but it keeps grabbing the header row and not the cells with the content I need. Can you help me with this?
  • To post as a guest, your comment is unpublished.
    matt · 1 months ago
    Hi,

    I have set up a code to filter a column to tomorrows date (works fine) then to put the filtered workbook into an email as a PDF (works ok) then filter this back to all (Works ok) For some reason the pdf comes through with no data and I cant for the life of me figure out why. Please can you help? Code below.

    Currently on row 122 so this should be covered with the below?

    Sub CallMacros()
    Call FilterTomorrow1
    Call Email_ActiveSheet_As_PDF
    Call FilterAll1
    End Sub
    Sub FilterTomorrow1()
    '
    ' FilterTomorrow1 Macro
    ' Filter delivery date from all to tomorrows date
    '

    '
    ActiveSheet.Range("$A$3:$T$329").AutoFilter Field:=6, Criteria1:=3, _
    Operator:=11, Criteria2:=0, SubField:=0
    ActiveWindow.SmallScroll Down:=-500
    End Sub
    Sub Email_ActiveSheet_As_PDF()

    'Do not forget to change the email ID
    'before running this code

    Dim OlApp As Object
    Dim NewMail As Object
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim FileFullPath As String

    With Application
    .ScreenUpdating = False
    .EnableEvents = False
    End With

    TempFilePath = Environ$("temp") & "\"

    TempFileName = ActiveSheet.Name & "-" & Format(Now, "dd-mmm-yy") & "Tomorrows Deliveries.pdf"

    On Error GoTo err
    With ActiveSheet
    .ExportAsFixedFormat _
    Type:=xlTypePDF, _
    Filename:=FileFullPath, _
    Quality:=xlQualityStandard, _
    IncludeDocProperties:=True, _
    IgnorePrintAreas:=False, _
    OpenAfterPublish:=False
    End With

    Set OlApp = CreateObject("Outlook.Application")
    Set NewMail = OlApp.CreateItem(0)

    On Error Resume Next
    With NewMail
    .To = "my email"
    .CC = ""
    .BCC = ""
    .Subject = "Tomorrows Deliveries"
    .Body = "Please see attached delivery schedule for tomorrow"
    .Attachments.Add FileFullPath '--- full path of the pdf where it is saved
    .Send 'or use .Display to show you the email before sending it.
    End With
    On Error GoTo 0

    Kill FileFullPath

    Set NewMail = Nothing
    Set OlApp = Nothing

    .ScreenUpdating = True
    .EnableEvents = True
    End With
    MsgBox ("Email has been Sent Successfully")
    Exit Sub
    err:
    MsgBox err.Description

    End Sub
    Sub FilterAll1()
    '
    ' FilterAll1 Macro
    ' Filter delivery due date from tomorrows date to select all
    '

    '
    ActiveSheet.Range("$A$3:$T$329").AutoFilter Field:=6
    End Sub
  • To post as a guest, your comment is unpublished.
    Kailing · 1 months ago
    Hi, can the reminder still be sent when the excel file is closed?
  • To post as a guest, your comment is unpublished.
    Jill · 2 months ago
    Hi,

    I would like to add another column in the code that allows me to write and separate message in the subject box, and another message for the email content. Can this be done?
  • To post as a guest, your comment is unpublished.
    Kayden · 2 months ago
    Hello,

    Can you modify this VBA to send automatic emails based on cell value instead of due dates? For instance, Column C2 will be a numeric value instead of a date; once it falls below XX number, then it initiates an email with subject The Park Project is due soon. Thank you!
  • To post as a guest, your comment is unpublished.
    parvana · 3 months ago
    Hello, thank a lot for the VBA code. I run it, but I have a problem. I tried several dates and realized the outlook is sending messages 1 day after the calibration date. I pu 7/14/2019
    7/15/2019
    7/16/2019
    7/17/2019
    7/18/2019
    7/19/2019
    7/20/2019
    7/21/2019 dates and after running the VBA code the excel sent me an email only for 7/19/2019; 7/20/2019; 7/21/2019 dates. Since today is 7/18/2019, it means the emails are 1 day after the calibration date. I wanted the messages to be sent the week before the due date.
  • To post as a guest, your comment is unpublished.
    David Brändle · 4 months ago
    Ich habe die VAB in der XLS Tabelle hinterlegt mit der korrekten Mail Adresse.
    Leider funktioniert es nicht. Woran kann es liegen? Gerne höre-lese ich von Ihnen. Vielen Dank.
  • To post as a guest, your comment is unpublished.
    Alex · 5 months ago
    Buenos días! ¿que modificación tendría que realizar para dejar seleccionadas las celdas con la información de fecha, texto y correo y no tener que seleccionarlas cada vez que se activa la macro?

    también me gustaría saber como introducir un CC, es decir, poder poner a otra persona en copia del correo. Gracias!
  • To post as a guest, your comment is unpublished.
    SerMFe · 5 months ago
    Hi,

    I have a question,

    If I want to select a prederterminate range of cells, how could i modify the code in this part:

    xLastRow = xRgDate.Rows.Count
    Set xRgDate = xRgDate(1)

    Toset automaticatly the cells?

    Thank you :)
  • To post as a guest, your comment is unpublished.
    LaThalia Y Echols · 6 months ago
    I am new to VBA. Is there a way to automatically run this program whenever the file is opened?
    • To post as a guest, your comment is unpublished.
      SerMFe · 5 months ago
      Yes, with


      Private Sub Workbook_Open()
      *Enter code here*
      End Sub
  • To post as a guest, your comment is unpublished.
    L Echols · 6 months ago
    Hello, I am new to VBA. Is there a way to have this program automatically run whenever the file is opened?
    • To post as a guest, your comment is unpublished.
      crystal · 5 months ago
      Hi L Echols,
      For automatically running the code when the file is opened, please double click to open the ThisWorkbook code window (locates in the left side of the Microsoft Visual Basic for Applications window) , select Workbook from the first drop-down list, and then copy the above VBA code (except the first and the last line) into the code window and paste between the given two lines. See the below attached screenshot:
      • To post as a guest, your comment is unpublished.
        Daniel Lee · 5 months ago
        This is awesome. I was wondering if there is a way to run the code without having to select the KuTools values every time? For clarification, I inputted this code and now whenever I open the workbook I still have to highlight the same columns. Is there a way to input the code to run a check on the same columns every time - as long as no edits to workbook have been made - to run the check and formulate an email based off said check? Thank you in advance.
      • To post as a guest, your comment is unpublished.
        Danny · 5 months ago
        This is awesome. I was wondering if there is a way to run the code without having to select the KuTools values every time? For clarification, I inputted this code and now whenever I open the workbook I still have to highlight the same columns. Is there a way to input the code to run a check on the same columns every time - as long as no edits to workbook have been made - to run the check and formulate an email based off said check? Thank you in advance.
        • To post as a guest, your comment is unpublished.
          crystal · 5 months ago
          Hi Danny,
          Please try the below code and change the ranges as you need.

          Public Sub CheckAndSendMail()
          'Updated by Extendoffice 2019/5/17
          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 = Range("C2: C4")
          If xRgDate Is Nothing Then Exit Sub
          Set xRgSend = Range("A2: A4")
          If xRgSend Is Nothing Then Exit Sub
          Set xRgText = Range("B2:B4")
          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 = "

          "
          xMailBody = ""
          xMailBody = xMailBody & "Dear " & xRgSendVal & vbCrLf
          xMailBody = xMailBody & "Text : " & xRgText.Offset(i - 1).Value & vbCrLf
          xMailBody = xMailBody & ""
          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
  • To post as a guest, your comment is unpublished.
    Dinesh B S · 6 months ago
    in the body i want the column a,b,c value in a table format, like the expired date once reached in the body column i want to print a,b,c cells details in table format
  • To post as a guest, your comment is unpublished.
    Sounder P · 7 months ago
    Hello Sir,

    This is very much helpful. I need 2 more enhancement in the same codes. I have to click on send button every time, it is fine as long as I have 10 email to be sent, what if I >25 emails to be sent in a single day. So please give me a code to send e-mail automatically upon selecting Due date , Recipient, Subject etc.

    Also please provide me with the code to add " CC" option as well


    Thanks

    Sounder P
    • To post as a guest, your comment is unpublished.
      crystal · 7 months ago
      Good day,
      Please try the below VBA code, hope I can help. Thanks for commenting.

      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 xRgCC = Application.InputBox("Please select the CC recipients?email column:", "KuTools For Excel", , , , , , 8)
      If xRgCC 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 xRgCC = xRgCC(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
      xRgCCVal = xRgCC.Offset(i - 1).Value
      xMailSubject = xRgText.Offset(i - 1).Value & " on " & xRgDateVal
      vbCrLf = "

      "
      xMailBody = ""
      xMailBody = xMailBody & "Dear " & xRgSendVal & vbCrLf
      xMailBody = xMailBody & "Text : " & xRgText.Offset(i - 1).Value & vbCrLf
      xMailBody = xMailBody & ""
      Set xMailItem = xOutApp.CreateItem(0)
      With xMailItem
      .Subject = xMailSubject
      .To = xRgSendVal
      .Cc = xRgCCVal
      .HTMLBody = xMailBody
      .Send
      End With
      Set xMailItem = Nothing
      End If
      End If
      Next
      Set xOutApp = Nothing
      End Sub
  • To post as a guest, your comment is unpublished.
    Sam Engel · 8 months ago
    Hi, I am using a modified version of this code, and I am rather new to VBA. I was curious if there was a possibility for when the email were to be sent, that the macro would be able to mark an X, or if someone had Complete, that an email would not send. I hope this all makes sense. Any help is very greatly appreciated. Little background, I am using this tool to run a due date check at 30 days, 60 days, and overdue. I want 1 email to go out at 30 days, 1 at 60 days, and then overdue as well. I am running this off of a VB script I wrote, so that I could automate it daily. Thanks!
  • To post as a guest, your comment is unpublished.
    S. Engel · 8 months ago
    Hi, I am using a modified version of this code, and I am rather new to VBA. I was curious if there was a possibility for when the email were to be sent, that the macro would be able to mark an X, or if someone had Complete, that an email would not send. I hope this all makes sense. Any help is very greatly appreciated.

    Little background, I am using this tool to run a due date check at 30 days, 60 days, and overdue. I want 1 email to go out at 30 days, 1 at 60 days, and then overdue as well. I am running this off of a VB script I wrote, so that I could automate it daily. Thanks!
  • To post as a guest, your comment is unpublished.
    Fabrisquie Borges · 9 months ago
    Correctly, it was not with Mr. Ivan, but with Mr. Austin.
    Thank you.
  • To post as a guest, your comment is unpublished.
    Fabrisquie Borges · 9 months ago
    Hello,
    Mr. Crystal, in your last conversation with Mr. Ivan, he asked you for the code to send e-mail every time the spreadsheet is opened instead of entering the codes each time.
    I need the same code, same situation, can you help please?
  • To post as a guest, your comment is unpublished.
    Rodrigo Vicente · 11 months ago
    Thank you very much for the contribution. I would like to know how to use fixed column selection without having to use kutools? that is, leave default columns of dates, receipts, and warnings?
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Good day,
      The below VBA code can help you. Please have a try.

      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 = Range("C2:C4") 'Please reference the due date column
      If xRgDate Is Nothing Then Exit Sub
      Set xRgSend = Range("A2:A4") 'Please reference the recipients?email column
      If xRgSend Is Nothing Then Exit Sub
      Set xRgText = Range("B2:B4") Enter the column with reminded content in your email
      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 = "

      "
      xMailBody = ""
      xMailBody = xMailBody & "Dear " & xRgSendVal & vbCrLf
      xMailBody = xMailBody & "Text : " & xRgText.Offset(i - 1).Value & vbCrLf
      xMailBody = xMailBody & ""
      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
      • To post as a guest, your comment is unpublished.
        niti · 9 months ago
        Dear Crytal,

        Thank for your sharing.

        I'm a beginner and I have a problem with code.

        xMailBody = ""
        xMailBody = xMailBody & "Dear " & xRgSendVal & vbCrLf
        xMailBody = xMailBody & "Text : " & xRgText.Offset(i - 1).Value & vbCrLf
        xMailBody = xMailBody & ""

        The text is not go to new line.
        Could you please help.

        Thanks
        • To post as a guest, your comment is unpublished.
          crystal · 9 months ago
          Ni niti,
          You need to add the line vbCrLf = "<br><br>" in front of the coldes.
          Such as:
          vbCrLf = "<br><br>"
          xMailBody = ""
          xMailBody = xMailBody & "Dear " & xRgSendVal & vbCrLf
          xMailBody = xMailBody & "Text : " & xRgText.Offset(i - 1).Value & vbCrLf
          xMailBody = xMailBody & ""
  • To post as a guest, your comment is unpublished.
    Ivan · 11 months ago
    Hi guys,


    Macro is great but I would like to ask something - if you have someone on the list without any date how to modifiy the vba code to exclude that guy? Now the code generates e-mails even for the guys without any date.


    Thanks!
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi Lvan,
      The code has been updated with the problem solving, please have a try. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    austin · 1 years ago
    I have got excel to send the email, but can I set this so it sends an email every time I open up excel instead of selecting the columns each time.

    I have a workbook with 24 pages so am looking to email automatically when the workbook is opened up.


    Many thanks.
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi,
      Do you mean check for the due date automatically across the workbook and send email when the workbook is openned up?
  • To post as a guest, your comment is unpublished.
    Dick Borman · 1 years ago
    Dont get it working. Using Office 365 so Outlook and Excel should be tight enough. Like in the post from "schou" 4 monts ago, it works up to step 5 but then nothing.
    A solution to this?
  • To post as a guest, your comment is unpublished.
    Edward Snyder · 1 years ago
    I need this to work across all worksheets in a workbook the future date will be manually entered in the same cell on every sheet and new sheets are created daily. I also need the worksheet name in the email so I will know which sheet is due
  • To post as a guest, your comment is unpublished.
    Diyaa · 1 years ago
    can we just input the details one time and the emails can be sent automatically, instead of always needing to select the columns?
    • To post as a guest, your comment is unpublished.
      crystal · 11 months ago
      Hi Diyaa,
      If you don't want to manually select the columns, please apply the below VBA code.
      Note: You onlyneed to select the due dates column after applying the code.

      Public Sub CheckAndSendMail()
      'Updated by Extendoffice 2017/9/14
      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
      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 = xRgDate.Offset(I - 1).Value
      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 = "

      "
      xMailBody = "Hi there" & vbNewLine & vbNewLine & _
      "This is line 1" & vbNewLine & _
      "This is line 2"
      Set xMailItem = xOutApp.CreateItem(0)
      With xMailItem
      .To = "Email Address"
      .CC = ""
      .BCC = ""
      .Subject = "send by cell value test"
      .Body = xMailBody
      .Display 'or use .Send
      End With
      Set xMailItem = Nothing
      End If
      Next
      Set xOutApp = Nothing
      End Sub
      • To post as a guest, your comment is unpublished.
        Thomas · 7 months ago
        Hello,
        I'm also pretty much of a beginner and I would like to ask another question for your great Sub.

        How can I send an email only if a certain mail-adress is in the regarding cell?

        I need this, because in my excel-tool i implemented some buttons for each person, who needs a reminder.

        Thank you very much in advance!!

        Thomas
  • To post as a guest, your comment is unpublished.
    Robert · 1 years ago
    This code froze my excel program when I ran it. Is it memory intensive?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Robert,
      The problem you mentioned does not appear in my case. May I have your Office version?
  • To post as a guest, your comment is unpublished.
    Maria · 1 years ago
    Me viene muy bien gracias por el aporte, solo me falta como puedo hacerlo automaticamente sin necesidad de hacerlo manualmente el envio del correo.
  • To post as a guest, your comment is unpublished.
    schou · 1 years ago
    I used your VBA code for sending emails based on a cell value but it doesn’t work.
    Everything up until step 5 works but no email is sent. Can anyone help me with this?
  • To post as a guest, your comment is unpublished.
    Brandon Pillay · 1 years ago
    Thank you for sharing.


    How would you add Cc inputs or multiple recipients?
    • To post as a guest, your comment is unpublished.
      schou · 1 years ago
      Hi Brandon,

      Sorry to comment on your post without an answer but were you able to get the VBA code to send an email?