Automating Outlook

paulmcdonnell

Ready to Help
Local time
Today, 04:39
Joined
Apr 11, 2001
Messages
167
Who's the DADDY on automating Outlook?

Hi Guys (The daddy test for those who use outlook automation a bit, or othermise.)


I'm quite happy to get my database to get me to email me when an urgent update is required. but i now want it to create an email only this time Loop ing through a record set and listing all those recorde returned in the BODY of a mail message.

Previously i've used
DoCmd.SendObject , , , Emailto, , , Subject, body & vbCrLf & vbCrLf & "" , False
and looped through the record set to create an individual email and send it. Now I need to loop through my recordset and add those selected recorde to the BODY of the email. I currenltly have one variable that = .body.

How could i get the loop to work programmatically that created the .body property with all the found records

I just can't seem to get this one.

HYCH
Paul
 
if i've understood the problem correctly, it sounds similar to something i have. my recordset is based on a form which loops through and processes each record. paul

This is what i use:

Dim rsemail As DAO.Recordset
'Dim fs As Object
'Dim objOutlookAttach As Outlook.Attachment
Dim objOutlook As Outlook.Application
Dim Emailto, strMessage As String

Set rsemail = Me.Recordset
Set objOutlook = CreateObject("Outlook.Application")
Set objoutlookmsg = objOutlook.CreateItem(olMailItem)

Do While Not rsemail.EOF

' process the body part here ie:
strMessage = strMessage & vbCrLf & rsemail.Fields("the_field_you_want_sent")

rsemail.MoveNext

Loop

With objoutlookmsg
.to = Emailto
.Subject = "whatever"
.Body = strMessage
.Display 'or .send
End With

Set objOutlook = Nothing
Set objoutlookmsg = Nothing
Set rsemail = Nothing
 
Big Thanks

Cheers Mate

That's just the ticket!

I'll try an help You where I can.

Paul
;)
 

Users who are viewing this thread

Back
Top Bottom