Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to have some event in order to fire this event. An Access database is just a file, so when you're not using it, it's not running any code.</p> <p>Doing a simple check every time the database is opened, maybe on the first form's On Load event would be the way to go. I assume your <code>DiscountEmail</code> RecordSet is the one querying for emails within the 3 day period.</p> <p>Your solution is to either put this in the onLoad event for your first form or to use another service. As far as not spamming the emailee more than once, just add a <code>emailSent</code> field or log sent emails to a different table, and handle it after the email is sent.</p> <p>Example query to find the relevant emails:</p> <pre><code>Select email from Users Where dateOfBirth between dateAdd("d",-3,Date()) AND dateAdd("d",3,Date()); </code></pre> <p>Do send an email, you could use SMTP and CDO. Create an email function called something like <code>sendEmail</code></p> <pre><code> Public Sub SendEmail(strTo as STring, strFrom as String, strSubj as String, strBody as String) Dim imsg As Object Dim iconf As Object Dim flds As Object Dim schema As String Set imsg = CreateObject("CDO.Message") Set iconf = CreateObject("CDO.Configuration") Set flds = iconf.Fields ' send one copy with SMTP server (with autentication) schema = "http://schemas.microsoft.com/cdo/configuration/" flds.Item(schema &amp; "sendusing") = cdoSendUsingPort flds.Item(schema &amp; "smtpserver") = "mail.myserver.com" 'your info here flds.Item(schema &amp; "smtpserverport") = 25 flds.Item(schema &amp; "smtpauthenticate") = cdoBasic flds.Item(schema &amp; "sendusername") = "email@email.com" 'more of your info flds.Item(schema &amp; "sendpassword") = "password" flds.Item(schema &amp; "smtpusessl") = False flds.Update With imsg .To = strTo .From = strFrom .Subject = strSubj .HTMLBody = strBody '.body = strBody '.Sender = "Sender" '.Organization = "My Company" '.ReplyTo = "address@mycompany.com" Set .Configuration = iconf .Send End With Set iconf = Nothing Set imsg = Nothing Set flds = Nothing End Sub </code></pre> <p>You could either loop through the resultset of your query and call your sendmail function for each email, or write a quick helper function that fetches and concatenates your email fields into a ";" delimited list, and just send the email once with multiple recipients.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload