E-mails

Try this

Private Sub CmdEmail_Click()
Dim rsEmail As DAO.Recordset
Dim strEmail As String
Dim strBody As String
Dim strbOdy1 As String
Dim strbody2 As String
Dim strbody3 As String
Dim strSubject As String
Dim strContactName As String
Dim StrCourseTitle As String
Dim strcoursefee As String
Set rsEmail = CurrentDb.OpenRecordset("QrySendEmails")

Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("Email").Value
StrCourseTitle = rsEmail.Fields("CourseTitle").Value
strcoursefee = rsEmail.Fields("Coursefee").Value
strBody = "According to our records, you are enrolled on the"
strbOdy1 = "When you enrolled, you informed us that you where in receipt of a Mean Tested Benefit. You have not however, shown the college proof that you are in fact in receipt of this benefit."
strbody2 = "Can you therefore please take proof of your benefit with you to the Information & Guidance desk as soon as possible, along with this e-mail."
strbody3 = "Failure to provide this proof, will result in you being invoiced with the next 14 days for the course fee, which is £"
strbody4 = "Should you have any queries regarding this e-mail, please contact the Finance Office on (01642) 865428."
strContactName = rsEmail.Fields("ContactName").Value
strSubject = rsEmail.Fields("subject").Value

DoCmd.SendObject , , , strEmail, , , _
strSubject, _
"Hello " & strContactName & vbCrLf & vbCrLf & strBody & StrCourseTitle _
& vbCrLf & vbCrLf & strbOdy1 _
& vbCrLf & vbCrLf & strbody2 _
& vbCrLf & vbCrLf & strbody3 & strcoursefee _
& vbCrLf & vbCrLf & strbody4, True

rsEmail.MoveNext

Loop
Set rsEmail = Nothing

MsgBox "Emails have been sent"
End Sub
 
Very first line of the code, you missed it out when you originally posted up your code.
 
I didn't miss it out.

When i time the code in, i can't get DAO as an option???
 
If i leave the first line in, i get the following error:

Compile error:

User-defined type not defined
 
Go into your code, Tools, References and select it from the list.
 
You might want to put its priority over Microsoft ActiveX Data Objects, too.
 
Ok have done that Hayley.

Now i still get the message saying that e-mails have been sent, but it's not sending any??????
 
OK.

my problem seems to be that while i am testing, the same student are appearing.

As soon as i select a different student, it works.

Any idea how i can stop this happening????
 
Email Code = True/Falss???

Hayley Baxter wrote

The code is currently set to True so that the email opens in outlook first, that was mainly for testing purposes. Set this to false and it will just send all the emails without opening in outlook.

How do you set the code to False???

Thanks for the help!

Rocky
 
Change the last argument of the DoCmd.SendObject line from True to False.
 
Email Outlook Alert

Thank you Mile-O-Phile,

Kind of embarrassed I didn't see that.

I now get an Outlook message saying

A program is trying to automatically send an email on you behalf. Do you want to allow this?

Is there a way send the email without having to press YES for each on?

Thanks again for the help.

Rocky
 
Re: Email Outlook Alert

rramon said:
Is there a way send the email without having to press YES for each on?

Only if you are willing to pay. :( Tthere's something called Redemption if you search the forum for the link by namliam that will bypass it.
 

Users who are viewing this thread

Back
Top Bottom