You have a form with a list box that shows the query of those expiring.
a button will scan the list, grabbing the email, then sending the warning.
Code:
sub btnSend_click()
for I = 0 to lstBox.listcount-1
LstBox = lstBox.itemdata(I)
vEmail = lstBox
SendEmail vEmail, "Your acct will expire", "expires on" & vDate
next
end sub
'-------
'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!! checkmark OUTLOOK OBJECTS in the vbE menu, Tools, References
'-------
Public Function SendEmail (ByVal pvTo, ByVal pvSubj, ByVal pvBody, optional pvFile ) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.To = pvTo
.Subject = pvSubj
.Body = pvBody
if not IsMissing(pvFile) then .Attachments.Add pvFile, olByValue, 1
.Send
End With
EmailO = True
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume Next
End Function