Send email to members

T

Tony

Hello i need help
i have found this cod to send email message to members and it works fine.
is there an easy way to change the cod so i can have the members first name
put in the Body of email, ex if i send email to (e-mail address removed) and his
name is Nicklas, i would like it to write "Hello Niklas" automatic in the
body

I have a querie named [email_adress], with field and [firstname]

Option Compare Database
Option Explicit

Private Sub Email_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim sTo As String

'Build To recipient list
Set db = CurrentDb()
Set rst = db.OpenRecordset("email_adress")

rst.MoveLast 'Ensure valid count
If rst.RecordCount > 0 Then
With rst
.MoveFirst
Do While Not .EOF
sTo = sTo & ";" & ![email]
.MoveNext
Loop
End With
sTo = Right(sTo, Len(sTo) - 1) 'trim leading ;
End If

'Send Email
DoCmd.SendObject acSendNoObject, , , sTo, , , "Subject Line Goes Here",
"Email Body Text Goes Here", True

End Sub

Hope for help
Tony
 
D

Dennis

Try this
Dim sFirstName as String
Inside the With statement set it
sFirstName = ![firstname]

DoCmd.SendObject acSendNoObject, , , sTo, , , "Subject Line Goes Here",
"Hello " & [sFirstName] & Chr(13) & Chr(13) & "Email Body Text Goes Here",
True
 
T

Totte via AccessMonster.com

Thank you for your replay
It works fine, but i get the same name to all adresses. My mistake that i
didnt explaine myself correctly. I wont to send the message to all members,
so i would like the name of the reciver to change for each members.
Is there any possibility to do that?

Thanks
Tony
Try this
Dim sFirstName as String
Inside the With statement set it
sFirstName = ![firstname]

DoCmd.SendObject acSendNoObject, , , sTo, , , "Subject Line Goes Here",
"Hello " & [sFirstName] & Chr(13) & Chr(13) & "Email Body Text Goes Here",
True
Hello i need help
i have found this cod to send email message to members and it works fine.
[quoted text clipped - 37 lines]
Hope for help
Tony
 
D

Dennis

Your code is to send 1 email message only to multiple email adresses built up
in the sTo string. You will need to bring the DoCmd.SendObject up into your
loop and send individual emails to each recipient.

Totte via AccessMonster.com said:
Thank you for your replay
It works fine, but i get the same name to all adresses. My mistake that i
didnt explaine myself correctly. I wont to send the message to all members,
so i would like the name of the reciver to change for each members.
Is there any possibility to do that?

Thanks
Tony
Try this
Dim sFirstName as String
Inside the With statement set it
sFirstName = ![firstname]

DoCmd.SendObject acSendNoObject, , , sTo, , , "Subject Line Goes Here",
"Hello " & [sFirstName] & Chr(13) & Chr(13) & "Email Body Text Goes Here",
True
Hello i need help
i have found this cod to send email message to members and it works fine.
[quoted text clipped - 37 lines]
Hope for help
Tony
 
T

Totte via AccessMonster.com

Hello Dennis
should i put the hole code DoCmd.SendObject, before or after the loop? please
show me.
and is there a easy way to put in the same message to all members?

Tony
Your code is to send 1 email message only to multiple email adresses built up
in the sTo string. You will need to bring the DoCmd.SendObject up into your
loop and send individual emails to each recipient.
Thank you for your replay
It works fine, but i get the same name to all adresses. My mistake that i
[quoted text clipped - 19 lines]
 
D

Dennis

Private Sub Email_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim sTo As String
Dim sFirstName as String

'Build To recipient list
Set db = CurrentDb()
Set rst = db.OpenRecordset("email_adress")

rst.MoveLast 'Ensure valid count
If rst.RecordCount > 0 Then
With rst
.MoveFirst
Do While Not .EOF
sTo = !
sFirstName = ![firstname]
'Send Email
DoCmd.SendObject acSendNoObject, , , sTo, , , "Subject Line Goes
Here",
sFirstName & Chr(13) & Chr(13) & "Email Body Text Goes Here", True
.MoveNext
Loop
End With
End If

End Sub
 
T

Totte via AccessMonster.com

Thanks for your help
I think i will use the original cod, I thougt i could do it more personnel

Tony

Private Sub Email_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim sTo As String
Dim sFirstName as String

'Build To recipient list
Set db = CurrentDb()
Set rst = db.OpenRecordset("email_adress")

rst.MoveLast 'Ensure valid count
If rst.RecordCount > 0 Then
With rst
.MoveFirst
Do While Not .EOF
sTo = !
sFirstName = ![firstname]
'Send Email
DoCmd.SendObject acSendNoObject, , , sTo, , , "Subject Line Goes
Here",
sFirstName & Chr(13) & Chr(13) & "Email Body Text Goes Here", True
.MoveNext
Loop
End With
End If

End Sub
[QUOTE]
Hello i need help
i have found this cod to send email message to members and it works fine.[/QUOTE]
[quoted text clipped - 37 lines][QUOTE]
Hope for help
Tony[/QUOTE][/QUOTE]
 

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