Private Sub Form_Timer() Dim MyDb As DAO.Database Dim rsEmail As DAO.Recordset Dim sToName As String Dim sSubject As String Dim sMessageBody As String Set MyDb = CurrentDb() Set rsEmail = MyDb.OpenRecordset("passport_expiry_15days", dbOpenSnapshot) With rsEmail .MoveFirst Do Until rsEmail.EOF If IsNull(.Fields(12)) = False Then Set email = CreateObject("CDO.Message") email.Subject = "Passport Expiry Notification 15 days" email.From = "HR System <email@example.com>" email.To = .Fields(12) email.TextBody = "Your passport will expire on " & .Fields(4) email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "admin" email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "admin" email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = "firstname.lastname@example.org" email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.domain.com" email.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 email.Configuration.Fields.Update email.Send Set email = Nothing MsgBox (.Fields(12)) End If .MoveNext Loop End With Set MyDb = Nothing Set rsEmail = Nothing End Sub
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE
Connect with Certified Experts to gain insight and support on specific technology challenges including: