Link to home
Start Free TrialLog in
Avatar of mckenziehenry
mckenziehenry

asked on

Sending an automated email via Outlook from Access 2010

I have a database for professional licenses, and I'd like to automatically send an email with the license expiration status report attached when the license is nearing it's expiration date.  I already have the query and reports ready to go, now I just need to get the automated email working properly.  Can someone please help me? Thank you.
Avatar of John Salle
John Salle

Instead of thinking about it sending through Outlook, you should have it send through your Email server. If that is Exchange on-site or Office 365 you can send up connectors to allow relay traffic. Otherwise you'll need to go to your mail provider with the proper settings. Typically they have some sort of mail relay options setup so end-users can email from Copiers and other devices that need it.
SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mckenziehenry

ASKER

Jeffrey--
I have the query setup to return "Expires within next 30 days" for all licenses that are within 30 days of their expiration date.  The report shows all licenses that expire within next 30 days.  I would like for the database to assess this date and send the notification email out "automatically" even when the database is not open. Does that clarify my earlier question?  

The email needs to tell recipient that all the licenses that are expiring within the next 30 days (includes state, license #, license type).  I originally planned for this to be the attached report, but if you can do it simpler without an attachment, I'm open to suggestions.  

Thank you very much.
"I would like for the database to assess this date and send the notification email out "automatically" even when the database is not open."

Access will not do anything unless it is open, and then needs some event to fire the action.

I have managed this type of setup previously by using Windows Scheduler to open the database, the database has an AutoExec Macro that executes the required actions and then closes the database. This would probably achieve what you want.

There's probably other third party products that would assist with this as well.


Kelvin
There's probably other third party products that would assist with this as well.
Like VBScript
What you can automate in VBA you can automate in VBScript.
What you can't do is any WinAPI stuff.

But you could conceivably execute all this in VBScript.
Thank you all for your feedback.

Jeffrey,
I'm not getting any error messages nor is any of this lighting up red:
 Dim rst As DAO.Recordset
 Set rst = CurrentDb.OpenRecordset("SELECT * FROM me.TblLicenseInfo WHERE License Expiration Date=#" & Format(DateAdd("d", -30, Now), "mmddyyyy") & "#")

 If Not (rst.EOF And rst.BOF) Then
   Do While Not rst.EOF
   '/ send the email
   DoCmd.SendObject acSendNoObject, , "", , "mckenzie.henry@woodgroup.com", , , "License is Expiring", "The licenses listed below are expiring within the next 30 days, please take appropriate action" & vbCrLf & "State" & rst!State & vbCrLf & "LicenseNumber" & rst!LicenseNumber & vbCrLf & "LicenseType" & rst!LicenseType, False
   
   rst.MoveNext
   Loop
 End If

However, and I'm sure this is a dumb question, I'm not sure exactly where to put it.  When I open the VBA editor, it's showing up on a report; shouldn't this be associated with the applicable table?