title: Send email from Access if DOB is within 'n' days
body: <p>I needed to make it in access so that I send an email to a certain customer when their date of birth is within 3 days.</p>
  
  <pre><code>Dim rs as dao.recordset
  set rs = currentdb.openrecordset(“DiscountEmail”)
  with rs
      if .eof and .bof then (No Records found for this query.)
          Msgbox “ No emails will be sent because there are no records from the query ‘DiscountEmail’ “
      else
          do until .eof 
  
              DoCmd.SendObject acSendNoObject, , , ![Email Address Field], , , “Happy Birthday!”, “Hello ” &amp; ![First Name Field] &amp; _
                      “, ” &amp; Chr(10) &amp; “Come in on your birthday and receive a 10% discount!”, False
  
              .edit
              ![Email_Sent_Date] = now()
              .update
              .movenext 
          loop
  
      End If
  end with
  
  If Not rs Is Nothing Then
      rs.Close
      Set rs = Nothing
  End If
  </code></pre>
  
  <p>I have this code, but now I just need to make it so that if a certain customer's birthday (In my table 'CustomerInfo') is within 3 days, it sends them an email saying that they can come in on their birthday and receive a discount. </p>
  
  <p>Also, I want to make it so that this happens automatically (so I don't have to press any button), but so that it sends it only once, and so I can send it again next year.</p>
  
  <p>Thanks in advance! :)</p>