e.mail from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Ok, I know how to e.mail to one recipent, but how do I set several e-mail
addresses:

Private Sub Command45_Click()
DoCmd.SendObject acSendNoObject, , , [EmailAddressFieldName]
End Sub

EmailAddressFieldName, should read: (e-mail address removed), (e-mail address removed).

The e-mail addresses must come fra a query..from custoner table...

I'm lost, please help

Ronny
 
Try this

docmd.SendObject acSendNoObject,,,[EmailAddressFieldName]& ";" &
[EmailAddressFieldName2] & ";" & [EmailAddressFieldName3],,,"aaaaa"

Or try and create a group, and send the mail to that group
 
Ronny,

You need to create a varSendTo variable, populate that variable, then use
that as your destination in your SendObject command.

You don't indicate how you are determining which email addresses you want to
send this to, so I'll assume you have a table which contains a SendThis
field, which has a data type of Yes/No, and have a form where you have
"checked" all of the records you want to send the email to. In that case,
you need to add code similiar to the following to the command button you are
using to implement the SendObject code.

'Make sure you have a DAO reference in your database

Private Sub Command45_Click()

Dim rs as DAO.Recordset
Dim varSendTo as Variant
Dim strSQL as string

strSQL = "SELECT [EmailAddress] FROM yourTable WHERE [SendThis] = -1"
Set rs = Currentdb.Openrecordset(strSQL)
Do While not rs.EOF
varSendTo = (varSendTo + ";") & rs([EmailAddress])
rs.movenext
Loop
rs.close
set rs = nothing

DoCmd.SendObject acSendNoObject, , , varSendTo

End Sub

BTW, I would change the name of your command button, and any of the other
controls on your form that you have allowed to be defaulted by access.
Leaving the Access default name for controls can be very confusing when you
are trying to debug code. I recommend you take a look at the following for
an explaination of one of the standard naming conventions :

http://www.mvps.org/access/general/gen0012.htm

HEH
Dale
 
Solution:

Private Sub Email_Click()
Dim rs As ADODB.Recordset
Dim varSendTo As Variant
Set rs = New ADODB.Recordset

rs.Open "SELECT Customer.Email FROM Customer WHERE (((Customer.Email)Is
Not Null))ORDER BY Customer.Email", CurrentProject.Connection

Do Until rs.EOF
varSendTo = (rs!Email + ";") & varSendTo
rs.MoveNext
Loop
rs.Close
Set rs = Nothing

DoCmd.SendObject acSendNoObject, , , , , varSendTo


End Sub
 

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

Back
Top