Send Query In Email Body

hootie318

Registered User.
Local time
Today, 04:13
Joined
Oct 28, 2003
Messages
130
I almost have what I need, but I am not quite there. I am a VBA novice and need help. I couldnt understand some of the code I have searched for on this topic.

I have a query that returns exactly the results I want. By using a SendObject macro I can accomplish sending the message with a .txt file attached. What I want to do is instead of having the attachment I want to send my query "FaxReportQueryReport" in the body of the email. No set address, just a set RE: line of "Today's Deliveries".
 
hootie318 said:
I have a query that returns exactly the results I want. By using a SendObject macro I can accomplish sending the message with a .txt file attached. What I want to do is instead of having the attachment I want to send my query "FaxReportQueryReport" in the body of the email. No set address, just a set RE: line of "Today's Deliveries".

No set address? Not sure I understand what you mean there. You will need to do this as a module, not a macro. You need to get the data from your query, and add it to a string, then use this string as the body text of your email. How much data is there in the query, and what sort of format is it in?
 
The query will have between 25 to 26 lines no more no less. It will not have a set email address. I dont know of a way to add it by code. I have seen code, but I dont know what to add and where.
 
Is it a table format or is it a bodu of information. Why isn't an attachment an option? You can convert your macro to a modules.

If you search this forum for recordsets, you will see plenty of examples of code. If you post an export of a sample query you want to send I will see what I can do.
 
I just changed jobs, the machine I am on has NO wizards. I am having to do everything manually. Here is an example of my code:

Private Sub Command28_Click()
On Error GoTo ErrorHandler

Dim strToWhom As String
Dim strSubject As String
Dim strMsgBody As String

strSubject = "Delivery Asignments"
strToWhom = "me@anyplace.com"
strMsgBody = ??????????

DoCmd.SendObject , , , strToWhom, , , strSubject, strMsgBody, True

Exit Sub
ErrorHandler:
Select Case Err.Number
Case 2501
Resume Next
Case Else
MsgBox "Err " & Err.Number & ": " & Err.Description
End Select
End Sub

I can get everyhitng to work except strmsgbody = I dont know what to put to return my query results or to even go another route and send a report. The closest I got was sending one record, but it was bunched together.
 
Is there any way to do it with a report using my code instead? Would that be easier?
 
I would open a relay form with the result in it , and refer the emailbody to the form content.
if mail sent go to next record and send again..
create a loop..
 

Users who are viewing this thread

Back
Top Bottom