Hey all i am using Access 2003 on Win Xp and i have been trying to make this code send emails to the users stored on each record. So far is works, except in the body of the email i need it to say a number of things, such as Dear (user), your current quota is (quota), and so on.
So far i can send the emails to multiple users but when it comes down to writing the message i cannot enter in more than one "rec("field )".
In my database i have four fields which are labeled Email, User, Name, Surname.
This code is VB btw
Thank you
Here is the code:
So far i can send the emails to multiple users but when it comes down to writing the message i cannot enter in more than one "rec("field )".
In my database i have four fields which are labeled Email, User, Name, Surname.
This code is VB btw
Thank you
Here is the code:
Code:
Public Sub SendMessage()
Dim ol As Outlook.Application
Dim msg As MailItem
Dim rec As DAO.Recordset
Dim intCount As Integer
Dim intLoop As Integer
Set ol = New Outlook.Application
Set rec = CurrentDb.OpenRecordset("q1")
If Not (rec.BOF And rec.EOF) Then
rec.MoveLast
rec.MoveFirst
intCount = rec.RecordCount
For intLoop = 1 To intCount
Set msg = ol.CreateItem(olMailItem)
msg.Subject = "ENTER YOUR SUBJECT HERE"
msg.To = rec("Email")
msg.Body =
msg.Send
Set msg = Nothing
rec.MoveNext
Next intLoop
End If
Set rec = Nothing
Set ol = Nothing
End Sub
Comment