Question about Outlook and Access

sachin30us

New member
Local time
Today, 02:35
Joined
May 19, 2011
Messages
2
Hello All,

I am a novice in VBA programming and I am using Access 2003. This is what i am trying to do. I have a table which has four fields Namely. I have about 160 records similar to the one below.

Name Place Animal Thing Identifier
John UK Lion Car JohnUKLionCar
Jason US Tiger Pen JasonUSTigerPen

I am trying to create a module that does the following to the body of the email. It must pick the name John from the Name field and place it on the body of the email. something like this.

Dear John,

So I would one email created for John. Below that it must have a snapshot of the record of the table. something like below excluding the identifier.

Name Place Animal Thing
John UK Lion Car

So the first email must look like :

Dear John,

Name Place Animal Thing
John UK Lion Car

and the secone email must look like

Dear Jason,

Name Place Animal Thing Identifier
Jason US Tiger Pen JasonUSTigerPen

Please help.

Warm Regards,

Sachin30us
 
Welcome to the Forum,

Take a look at this code, I have used this a few years ago when sending out some invites.

What I did was create a form and added the text in the fields then it generates an email to each person

Private Sub CmdPressemail_Click()
Dim olapp As Outlook.Application
Dim olmailmessage As Outlook.MailItem
Dim olrecipient As Outlook.Recipient

Dim StrMsg As String

Dim rcdSQL As Variant

Dim db As DAO.Database
Dim rcd As Recordset

Set db = CurrentDb()

Set rcdSQL = db.OpenRecordset("SELECT * FROM qryEmailAwaitingResponseEastMidlands WHERE [AwardEventAttendance]='East Midlands'")

Set olapp = New Outlook.Application


Do Until rcdSQL.EOF

If rcdSQL!.Value <> "" Then
Set olmailmessage = olapp.CreateItem(olMailItem)

olmailmessage.Recipients.Add (rcdSQL![Email].Value)

olmailmessage.Subject = Me.txtsubject.Value
olmailmessage.Body = Me.txtbody.Value & vbCrLf

'If blnKnownRecipient = True Then
olmailmessage.Send
Set olmailmessage = Nothing
End If
rcdSQL.MoveNext
Loop
'olapp.Quit
Set olapp = Nothing
End Sub[/QUOTE]
 

Users who are viewing this thread

Back
Top Bottom