Email a query

ECEK

Registered User.
Local time
Today, 23:27
Joined
Dec 19, 2012
Messages
717
I have a command button that opens Outlook (and contains my signature...wohooo!!!).

Private Sub Command2_Click()
Dim objOutlook As Object
Dim objItem As Object

Set objOutlook = CreateObject("Outlook.Application")
Set objItem = objOutlook.CreateItem(olMailItem)
With objItem
.Subject = Title
End With
objItem.Display
End Sub


I want to attach a Query called "New Process" to the email along with a subject and body text.

Would sombody be so kind as to illustrate how best to do this in Access 2010.

Much obliged
 
U can use something similar

Code:
Private Sub Command0_Click()
Dim objOutlook As Object
Dim objItem As Object
[COLOR=Blue]Dim Mydb As Database
Dim Rst As Recordset
Dim body[/COLOR]

[COLOR=Blue]Set Mydb = CurrentDb
Set Rst = Mydb.OpenRecordset("select", dbOpenForwardOnly)
With Rst
Do While Not .EOF
body = body & ![CodCl] & " | " & ![produs] & " | " & ![grupa] & vbCrLf
.MoveNext
Loop
End With[/COLOR]


Set objOutlook = CreateObject("Outlook.Application")
Set objItem = objOutlook.CreateItem(olMailItem)

With objItem
.Subject = Title
[COLOR=Blue].body = "testing" & vbCrLf & " " & body[/COLOR]
End With
objItem.Display
Rst.Close
Set Rst = Nothing
End Sub
I would export the query result, and attach it to an email, i consider it a faster way of sending data, because if the query has a lot of records it would take access some time to write all of the data.
 
Last edited:
Compile error:
Expected user-defined type, not project

Mydb As Database

Does anybody have any code to export a query, email it (with a signature) then delete the file?
 
I can use a macro to do what I want to do using EMailDatabaseObject. It just doesnt add my signature.
 
The use of Database is an ambiguity. Use Mydb As DAO.Recordset
 

Users who are viewing this thread

Back
Top Bottom