make a table of emails, tEmails. you could even have groups,
eAddr, person, group
jo@work.com, jo smith, Acct
bob@work.com, bob jones, Acct
jo@work.com, jo smith, BigMeet
you can add ,subtract users at will.
make a form, put a listbox on it, connect it to the tEmail
add a combo box with the differnt groups. (a query to pull unique Group from tEmails table)
picking a group will filter the names.
make a box to put in the email message,
a button to scan thru the list box and send the message to each.
Code:
'------------
Public Sub btnSend_click()
'------------
Dim vTo, vSubj, vBody, vRpt
Dim vFilePath
dim i as integer
For i = 0 To lstEAddrs.ListCount - 1
vRpt = lstEAddrs.ItemData(i)
lstEAddrs = vRpt
vTo = lstEAddrs.Column(2)
vBody = me.txtMessage
vSubj = me.txtSubj
Call Email1(vTo, vSubj, vBody)
Next
End Sub
'-------
'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!! checkmark OUTLOOK OBJECT LIBRARY in the vbE menu, Tools, References
'-------
Public Function Email1(ByVal pvTo, ByVal pvSubj, ByVal pvBody,optional ByVal 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