sending email to multiple recipients from 1 form

redknite

New member
Local time
Today, 02:57
Joined
Jan 25, 2011
Messages
7
Hey all,
I have a table (tblSales) that has several contacts in it. I want to send 1 email to all recipients where their check box is checked.

here is my code
Code:
Private Sub SendBtn_Click()
Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")
Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)
With OlkMsg
Dim OlkRecip As Outlook.Recipient
Set OlkRecip = .Recipients.Add(Me![AgentL.E-mailAddress])
If ([LenderC]) = False Then
Else
.Recipients.Add (Me![Lender.E-mailAddress])
End If
If (Me![BuyerC]) = False Then
Else
.Recipients.Add (Me![Buyer.E-mailAddress])
End If
If (Me![SellerC]) = False Then
Else
.Recipients.Add (Me![Seller.E-mailAddress])
End If
If (Me![AgentSC]) = False Then
Else
.Recipients.Add (Me![AgentS.E-mailAddress])
End If
If (Me![EscrowC]) = False Then
Else
Set OlkRecip = .Recipients.Add(Me![Escrow.E-mailAddress])
End If
OlkRecip.Type = olTo
.Subject = Me![tblProperty.Address]
.Display
End With
Set Olk = Nothing
Set OlkMsg = Nothing
Set OlkRecip = Nothing
End Sub

I can't seem to get this to work with muliple email addresses. Any thoughts?

I've attached an image of the form. Fields with "C" at the end are checks.
 

Attachments

  • Capture.JPG
    Capture.JPG
    80 KB · Views: 191
instead of doing this manually hard coded, you should really loop the rs, or something at least.

what does "can't seem to get this to work" mean, exactly??
 
How do I loop?

The error that I gert when i run the code above is:

"Run-time error '438' : object doesn't support this property or method."

I think it's because it's still in the "recipient.add" section...

Thanks for your help i really do appreciate it.
 
I can't test this as I don't have Outlook, but I seem to recall using .To

Try this code, you will see what I mean

Code:
Private Sub SendBtn_Click()
Dim Olk As Outlook.Application
Set Olk = CreateObject("Outlook.Application")
Dim OlkMsg As Outlook.MailItem
Set OlkMsg = Olk.CreateItem(olMailItem)
With OlkMsg

Dim RecipientString As string
RecipientString = (Me![AgentL.E-mailAddress])
If ([LenderC]) = False Then
Else
RecipientString = RecipientString & ";" & (Me![Lender.E-mailAddress])
End If
If (Me![BuyerC]) = False Then
Else
RecipientString = RecipientString & ";" & (Me![Buyer.E-mailAddress])
End If
If (Me![SellerC]) = False Then
Else
RecipientString = RecipientString & ";" & (Me![Seller.E-mailAddress])
End If
If (Me![AgentSC]) = False Then
Else
RecipientString = RecipientString & ";" & (Me![AgentS.E-mailAddress])
End If
If (Me![EscrowC]) = False Then
Else
RecipientString = RecipientString & ";" & (Me![Escrow.E-mailAddress])
End If
.To = RecipientString
.Subject = Me![tblProperty.Address]
.Display
End With
Set Olk = Nothing
Set OlkMsg = Nothing

End Sub
 

Users who are viewing this thread

Back
Top Bottom