Hopefully someone will be able to help me figure this one out. I have done some research, and so far no luck.

I have a function that loops through my spreadsheet and checks the due date for an invoice and whether or not it has been approved and sends out a reminder email to the approver with the invoice as an attachment.

The first email sent works great, the second attaches the first invoice and the newly selected invoice, the third email attaches the first 2 and the selected one, and so on.

Does anyone know of a way to clear out attachments after the mail is sent so only the selection attaches to the next email? I appreciate any help I can get!

Here's my coding:

Sub Reminder()
Sheets("INVOICES").Activate
    Dim i As Integer
    Dim Sendmsg
    Dim iMsg As Object
    Dim iConf As Object
    Dim Flds As Variant
    Dim TextBody As String
    Dim ApprovedTextBody As String
    Dim Finfo As String
    Dim FilterIndex As Integer
    Dim FileName As Variant
    Dim Title As String
           
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With
    
    Finfo = "All Files (*.*),*.*"

    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.Configuration")

    iConf.Load -1    ' CDO Source Defaults
    Set Flds = iConf.Fields

 'mail server details
    With Flds
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mail_server
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Update
    End With

    i = 1
    Do While Worksheets("INVOICES").Cells(i, 3) <> ""
    
        If Worksheets("INVOICES").Cells(i, 12).Value <= Date + 7 And Worksheets( _
        "INVOICES").Cells(i, 18) = "" Then
        
            Sendmsg = MsgBox(Prompt:="Are you sure you're ready to send?", _
            Buttons:=vbYesNo, Title:=Worksheets("INVOICES").Cells(i, 6).Text & " Inv " & _
                Worksheets("INVOICES").Cells(i, 5).Text & " " & Worksheets("INVOICES").Cells(i, 11).Text)

            If Sendmsg = vbNo Then
            Exit Sub
            Else
            FileName = Application.GetOpenFilename(Finfo, FilterIndex, Title)
            invoice_file_name = FileName
            
            TextBody = "Hello," & vbNewLine & vbNewLine & _
                "The attached invoice is still awaiting approval. Kindly advise if this invoice is " & _
                "approved for payment as soon as you get a chance. " & vbNewLine & vbNewLine & _
                Worksheets("INVOICES").Cells(i, 6).Text & " Inv " & _
                Worksheets("INVOICES").Cells(i, 5).Text & vbNewLine & "JSID " & _
                Worksheets("INVOICES").Cells(i, 3).Text & vbNewLine & _
                Worksheets("INVOICES").Cells(i, 11).Text & vbNewLine & _
                Worksheets("INVOICES").Cells(i, 7).Text & " " & Worksheets("INVOICES").Cells(i, 8).Text & _
                vbNewLine & vbNewLine & "Thank you," & vbNewLine & "cschoyer"
    
                With iMsg
                Set .Configuration = iConf
                    .To = Worksheets("INVOICES").Cells(i, 13).Text + "@xyz.com"
                    .CC = ""
                    .BCC = ""
                    .From = """cschoyer"" <[email protected]>"
                    .Subject = "Pending Approval " & Worksheets("INVOICES").Cells(i, 6).Text & " Inv " & _
                             Worksheets("INVOICES").Cells(i, 5).Text & " JSID " & _
                             Worksheets("INVOICES").Cells(i, 3).Text
                    .TextBody = TextBody
                    .AddAttachment invoice_file_name
                    .Send
                End With
            End If
            invoice_file_name = ""
        End If

    i = i + 1
    Loop
    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With

End Sub