E-Mail and Recordsets??

ZMAN2

Registered User.
Local time
Today, 00:30
Joined
May 6, 2003
Messages
37
I found this code while doing a search and since I'm not familiar with recordsets I am at a loss. I did some additional searches on recordsets and found lots of useful information,but none that entirely answered my questions.

1. I am trying to include the entire recordset or query in the body of an email the following just includes the first record of fieid1
2. Can you also include the field names of the table you are trying to include?
3. Basically, I would like to include the query "as-is" in the body of the email
4. Can there also be additional fixed text preceeding the inclusion of this table?
5. Can the e-mail format be coded as plain text vs. HTML?

Any help would be appreciated.

**********************************************************

Public Sub SendMail()
Dim outApp As Outlook.Application
Dim outItem As Outlook.MailItem
Dim strEMailMsg As String ' message text
Dim Db as Dao.Database
Dim Rst as Dao.Recordset

' SET YOUR DB INSTANCE
Set Db = Currentdb
'CREATE YOUR RECORDSET
Set Rst = Db.Openrecordset("MyQuery")

' Use your details from the recordset

strEMailMsg = Rst![Field1]

Set outApp = New Outlook.Application
Set outItem = outApp.CreateItem(olMailItem)

With outItem
.To = "Anybody"
.Subject = "Test"
.HTMLBody = strEMailMsg
.Display
End With

Set Db = Nothing
Set Rst = Nothing
Set outItem = Nothing
Set outApp = Nothing
End Sub
 
z,

Just some things to comment on:

strEMailMsg = Rst![Field1] & vbCrLf & Rst![Field2] & vbCrLf & Rst![Field3] ...

Also:

Code:
While Not Rst.EOF and Not Rst.BOF
   ' Do some things ...
   Rst.MoveNext
   Wend

Wayne
 

Users who are viewing this thread

Back
Top Bottom