Unanswered: Send email to list of recipients Problem
I have a button on a form that when clicked, will send an email to a list of recipients. I get the following error when the code runs.
Run-Time Error '424'
It errors on the line: .Recipients.Add (Tables!Members!Email)
Please see attached code.
Any help would be greatly appreciated!
Private Sub Command0_Click()
Dim MyDB As Database
Dim MyRS As Recordset
Dim ol As Outlook.Application
Dim ns As NameSpace
Dim msg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim att As Attachment
Dim TheAddress As String
Set MyDB = CurrentDb
' Create the Outlook session.
Set ol = Outlook.Application
Set ns = ol.GetNamespace("MAPI")
' Create the e-mail message.
Set msg = Outlook.Application.CreateItem(olMailItem)
' Add the To recipients to the e-mail message.
' Set the Subject, the Body, and the Importance of the e-mail message.
.Subject = "Subject of email"
.Body = "Body of email"
.Importance = olImportanceHigh 'High importance
' Resolve the name of each Recipient.
For Each objOutlookRecip In .Recipients
If Not objOutlookRecip.Resolve Then
Set objOutlookMsg = Nothing
Set objOutlook = Nothing