Results 1 to 8 of 8

Send email based on due dates

Threaded View

  1. #1
    Registered User
    Join Date
    08-05-2019
    Location
    England
    MS-Off Ver
    Office 2016
    Posts
    19

    Send email based on due dates

    Hi

    I have recently located someones coding from these pages to send emails based on specific due dates. I was provided with the below code which sort of works, however, if the code identifies more than one person with the same end date, it only shows the email for the last person listed. The code will update the spreadsheet to say it has identified and created an email however, it will only show 1 x pane to be sent and not the seven it has identified.

    ANY HELP WOULD BE APPRECIATED
     Private Sub Workbook_Open()
    
       
        Dim i As Long
        Dim OutApp, OutMail As Object
        Dim strto, strcc, strbcc, strsub, strbody As String
        
        Set OutApp = CreateObject("Outlook.Application")
        OutApp.Session.Logon
        Set OutMail = OutApp.CreateItem(0)
        
        
        For i = 2 To Range("C65536").End(xlUp).Row
            If Cells(i, 43) <> "Y" Then
                If Cells(i, 21) - 14 < Date Then
                    
                    strto = Cells(i, 44).Value 'email address
                    strsub = "PSR Contractor " & Cells(i, 6).Value & " is due on Due date " & Cells(i, 21).Value 'email subject
                    strbody = "Dear " & Cells(i, 6).Value & vbNewLine & "please update your project status" 'email body
                    
                    With OutMail
                        .To = strto
                        .Subject = strsub
                        .Body = strbody
                        '.Send
                        .display
                                        
                    End With
                    On Error Resume Next
                    Cells(i, 42) = "Mail Sent " & Now()
                    Cells(i, 43) = "Y"
                    
                End If
            End If
        Next
        
        Set OutMail = Nothing
        Set OutApp = Nothing
        
    
    End Sub
    Last edited by JohnPorter85; 11-18-2019 at 09:57 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create Email to automaticaly send email based on Renew Date
    By Howardc1001 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-30-2019, 02:05 AM
  2. Send email based on dates to hide columns
    By Jamesraywebber85 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-20-2019, 05:36 PM
  3. send automatic email on multible dates until checked off completed.
    By jz75455 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-16-2016, 03:53 AM
  4. Send Email Based on 2 Dates
    By onelifestyle in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-22-2015, 04:16 PM
  5. Send delayed email from dates in cell's in excel
    By Ryan Nielsen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-05-2013, 03:06 PM
  6. Conditional formating that will send email to 5 oldest dates in a column
    By ayan1988 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-23-2013, 11:25 AM
  7. Check dates and then send email to user.
    By dutchdog in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-10-2012, 03:36 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1