Aug 23 2022 09:44 PM - edited Aug 23 2022 09:49 PM
I've got a fairly good grips on understanding the basics of Access but I'm fairly new to coding and can't really find anything that explains how to do what I need.
So the overall aim that I want this code to do is upon opening my Main Menu form reminders for tasks due to be emailed out to the employees looking after that task. So I want an email reminder sent out 30 days before due date and then another sent when the task becomes overdue. I want to do this for range of things but currently am just looking at licence expires for every expiry.
So that you have a clear Idea of what my database is looking like below is a list of table and Queries.
Tables:
EmployeeT (Headings: EmployeeID, FirstName, LastName, PhoneNumber, PersonalEmail, WorkEmail, Department, Active, AssignedToID)
DriversLicenceT (Headings: LicenceID, EmployeeID, LicenceNumber, LicenceExpiry, LicenceType, Copy of Licence)
AssignedToT (Headings: AssignedToID, EmployeeID, AssignedToEmployeeEmail
SmashLicenceT (Headings:SmashLicenceID, EmployeeID, Smash Licence(this is a yes/no tick box), SmashLicenceExpiry, CopyOfSmashLicence
Queries SQL Code:
AllActiveLicenceExpiryOverdue
.Body = "Please be aware that " & FirstName & LastName & " Licence is Due for renewal in the next 30 days. Licence Expiry is -" & LicenceExpiry & ",<P>" & _
"Please update New Licence Expiry date and upload copy of New Drivers Licence" & ",<P>" & _
"Kind Regards" & ",<P>" & _
"Kym Wilson"
.To = AssignedToEmployeeEmail
.cc = PersonalEmail (Can't get this to work either so any help here would be greatly appreciated)
.Subject = "Licence Expiry Due in 30 Days " & Now()
THANK YOU IN ADVANCE!!! Happy to provide for info if required.
Aug 23 2022 10:16 PM
Aug 24 2022 09:25 PM
This partial works but not completely. So I want the email reminders to be automatically sent upon opening the main menu (See below)
This is the code I am using
'SEND EMAIL REMINDER FOR LICENCE EXPIRY IN 30 DAYS
Dim O As Outlook.Application
Dim M As Outlook.MailItem
Set O = New Outlook.Application
Set M = O.CreateItem(olMailItem)
With M
.BodyFormat = olFormatHTML
.HTMLBody = "Please be aware that " & FirstName & LastName & " Licence is Due for renewal in the next 30 days. Licence Expiry is -" & LicenceExpiry & ",<P>" & _
"Please update New Licence Expiry date and upload copy of New Drivers Licence" & ",<P>" & _
"Kind Regards" & ",<P>" & _
"Kym Wilson"
.To = AssignedToEmployeeEmail
.CC = PersonalEmail
.Subject = "Licence Expiry Due in 30 Days " & Now()
.Display
End With
Set M = Nothing
Set O = Nothing
This will open my outlook but wont put the emails in from the form because I haven't directed it to form that I need to use and I don't know how to do this? below is the form I need the code to take the information from (p.s. I know personal email is not in there )
Thanks in advance
Aug 25 2022 08:14 AM