Sending to more than one person

M

Matthew

I have found the sample database Contacts, which has an
example of sending an email. I have taken the code from
there and have tried to adjust to meet my needs.

What I would like to do is not send an email to just the
one person but to everyone listed in the form. Also rather
than a single email to each person, I would like 1 email
to everyone.

When I push the command button currently even though all
the emails are in the form it only, does the first email
in the list.
Is there a way to get all the emails in the form into the
email I will be sending.

I have a form which has the Field [txtEmailName] and a
Command Button cmdEmail

I also have the follow code:
On the OnClick button on the Command button:

Private Sub cmdEmail_Click()
On Error GoTo HandleErr
If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
EnableEmail
ExitHere:
Exit Sub

HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, _
, "Form_Contact.cmdEmail_Click"
End Select
Resume ExitHere

End Sub

On the OnCurrent button for the form.

Private Sub Form_Current()
On Error Resume Next
EnableEmail
End Sub


Private Sub EnableEmail()
' Update the email button
On Error Resume Next
cmdEmail.HyperlinkAddress = "mailto: " & [txtEmailName]
End Sub


Any help will be gratefully received.

Thanks

M
 
P

Paul Overway

You can only send to one recipient using a mailto: hyperlink. You need to
loop through your recordset and send to each recipient individually, or use
another method...i.e., program Outlook and add them via the recipients
object
 
A

Al Moroz

1st, look in Help -- there is sample code. 2nd, look on
Microsoft's site, even more code.

Here is code that loops through a Recordset and creates 1
messages with all email addresses in the BCC field
(Remember to DIM the variables).

Set objOutlook = New Outlook.Application
Set objMessage = objOutlook.CreateItem(olMailItem)
Set Db = CurrentDb()
Set Rs = Db.OpenRecordset("<Table_or_Query>",
dbOpenDynaset)

'1 message to multiple Members using BCC field
With objMessage
objMessage.Subject = "<Enter_Subject>"
objMessage.Body = "<Enter_Body>"
With Rs
.MoveFirst
Do Until .EOF
strBCC = strBCC & !email & ";"
.MoveNext
Loop
End With
End With

'Strip-off last ';'
strBCC = Left$(strBCC, Len(strBCC) - 1)
objMessage.BCC = strBCC
objMessage.Save 'Creates a Draft for review
'objMessage.Send Don't want to Send immediately
Rs.Close
Set Rs = Nothing
Db.Close
Set Db = Nothing
Set objMessage = Nothing
Set objOutlook = Nothing

Al Moroz
www.abacus-strategies.com

**NOTE: Do not respond to the email address, it's for
Newsgroups only
 
L

Lynn Trapp

Check out the following website:

http://www.granite.ab.ca/access/emailsend.htm

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm



matt said:
Oh dam.

A loop - is that the best way to go? Are they easy to
write?

I have never heard of program Outlook and add them via the
recipients?
Is there any other way I can achieve what I am trying to
do?

Tanks.

M
-----Original Message-----
You can only send to one recipient using a mailto: hyperlink. You need to
loop through your recordset and send to each recipient individually, or use
another method...i.e., program Outlook and add them via the recipients
object

--
Paul Overway
Logico Solutions, LLC
www.logico-solutions.com


Matthew said:
I have found the sample database Contacts, which has an
example of sending an email. I have taken the code from
there and have tried to adjust to meet my needs.

What I would like to do is not send an email to just the
one person but to everyone listed in the form. Also rather
than a single email to each person, I would like 1 email
to everyone.

When I push the command button currently even though all
the emails are in the form it only, does the first email
in the list.
Is there a way to get all the emails in the form into the
email I will be sending.

I have a form which has the Field [txtEmailName] and a
Command Button cmdEmail

I also have the follow code:
On the OnClick button on the Command button:

Private Sub cmdEmail_Click()
On Error GoTo HandleErr
If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
EnableEmail
ExitHere:
Exit Sub

HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, _
, "Form_Contact.cmdEmail_Click"
End Select
Resume ExitHere

End Sub

On the OnCurrent button for the form.

Private Sub Form_Current()
On Error Resume Next
EnableEmail
End Sub


Private Sub EnableEmail()
' Update the email button
On Error Resume Next
cmdEmail.HyperlinkAddress = "mailto: " & [txtEmailName]
End Sub


Any help will be gratefully received.

Thanks

M


.
 
T

Tony Toews

matt said:
A loop - is that the best way to go? Are they easy to
write?

See the Sample Code illustrating looping through a DAO recordset page
at the Access Email FAQ at my website.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top