Forum Discussion

Cheri676's avatar
Cheri676
Copper Contributor
Aug 29, 2022
Solved

Help with Access VBA code to automate email!!!!!

I am trying to automate sending emails upon opening a Main Menu form based off of records in another query.  Then having a check box turn on once the email has been sent so it won't be sent again.  ...
  • XPS35's avatar
    XPS35
    Aug 30, 2022

    Cheri676 

    I have made a new setup for your code. It only shows the main structure. You have to insert the code for actually sending an email.

     

    Private Sub Form_Open(Cancel As Integer)
        Dim rec As Recordset
    
        Set rec = CurrentDb.OpenRecordset("SELECT * FROM AllActiveLicenceExpiryDueIn30DaysQ")
    
        Do Until rec.EOF
            If Not IsNull(rec!AssignedToEmail) And _
               Not rec!EmailSent30days Then
                
                'SEND EMAIL REMINDER FOR LICENCE EXPIRY IN 30 DAYS
                
                rec.Edit
                rec!EmailSent30days = True
                rec.Update
            End If
    
            rec.MoveNext
        Loop
    End Sub

     

     

Resources