473,396 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Access 97: Sending Report as Email Body not Attachment

Lee
As the subject states, I have been playing in the system trying to
figure out a method of using a report as the email body text.

So far, the closest I have come is the acFormatHTML. However, when
the report is more than one page, it autoformats the report to
multiple pages. I need one document.

Reason for doing this as text vs. attachment is in order to make the
message easier to view for the reader/receipent.

Any suggestions?

Here is the code:
Sub SendWithAtt(ByRef str_Message As str_EMAIL, Optional
str_ReportName As String, Optional dbl_OrderID As Double)
Dim CurrFile As String, olMailItem As Variant
Dim oApp As Object, m As Object
Dim SQL As String
Dim rst As Recordset, AppInTesting As Boolean

Set oApp = GetObject(, "Outlook.application")
If Err.Number <> 0 Then
Set oApp = CreateObject("Outlook.Application")
End If
On Error GoTo Err_SendWithAtt
If nz(dbl_OrderID, 0) > 0 Then
DoCmd.OpenReport str_ReportName, acViewPreview, "(orderid = "
& dbl_OrderID & ")"
Else
DoCmd.OpenReport str_ReportName, acViewPreview
End If

With oApp
Set m = .CreateItem(olMailItem)
With m
.To = str_Message.str_TO
.bcc = "my.email@address"
.Subject = str_Message.str_SUBJECT
.HTMLBody = ReportToHTML(Reports(str_ReportName))
.deferreddeliverytime = Now()
.deleteaftersubmit = True
.ReadReceiptRequested = False
.display
'.send
End With
End With
DoCmd.Close acReport, str_ReportName, acSaveNo
Set m = Nothing
Set oApp = Nothing

End Sub

Function ReportToHTML(Rpt As Report)

Dim obj_A As Object, obj_B As Object
Dim str_File As String

str_File = "C:\temp\report1.htm"

DoCmd.OutputTo acOutputReport, Rpt.Name, acFormatHTML, TempFile

Set obj_A = CreateObject("Scripting.FileSystemObject")
Set obj_B = fso.GetFile(TempFile).OpenAsTextStream(1, -2)

ReportToHTML = obj_B.ReadAll

obj_B.Close

Set obj_B = Nothing
Set obj_A = Nothing
Kill str_File

End Function
Nov 12 '05 #1
2 5500
What do you actually have in the report?? If it's just basically text, why
don't you put the text in a procedure and run the procedure to generate the
email? Even you require HTML formating, I still think that it's possible to
generate HTML formatted email right within the procedure. This removes any
uncertainty brought by the direct export of report into HTML.

herbert

"Lee" <le*****@yahoo.com> ¦b¶l¥ó
news:fe**************************@posting.google.c om ¤¤¼¶¼g...
As the subject states, I have been playing in the system trying to
figure out a method of using a report as the email body text.

So far, the closest I have come is the acFormatHTML. However, when
the report is more than one page, it autoformats the report to
multiple pages. I need one document.

Reason for doing this as text vs. attachment is in order to make the
message easier to view for the reader/receipent.

Any suggestions?

Here is the code:
Sub SendWithAtt(ByRef str_Message As str_EMAIL, Optional
str_ReportName As String, Optional dbl_OrderID As Double)
Dim CurrFile As String, olMailItem As Variant
Dim oApp As Object, m As Object
Dim SQL As String
Dim rst As Recordset, AppInTesting As Boolean

Set oApp = GetObject(, "Outlook.application")
If Err.Number <> 0 Then
Set oApp = CreateObject("Outlook.Application")
End If
On Error GoTo Err_SendWithAtt
If nz(dbl_OrderID, 0) > 0 Then
DoCmd.OpenReport str_ReportName, acViewPreview, "(orderid = "
& dbl_OrderID & ")"
Else
DoCmd.OpenReport str_ReportName, acViewPreview
End If

With oApp
Set m = .CreateItem(olMailItem)
With m
.To = str_Message.str_TO
.bcc = "my.email@address"
.Subject = str_Message.str_SUBJECT
.HTMLBody = ReportToHTML(Reports(str_ReportName))
.deferreddeliverytime = Now()
.deleteaftersubmit = True
.ReadReceiptRequested = False
.display
'.send
End With
End With
DoCmd.Close acReport, str_ReportName, acSaveNo
Set m = Nothing
Set oApp = Nothing

End Sub

Function ReportToHTML(Rpt As Report)

Dim obj_A As Object, obj_B As Object
Dim str_File As String

str_File = "C:\temp\report1.htm"

DoCmd.OutputTo acOutputReport, Rpt.Name, acFormatHTML, TempFile

Set obj_A = CreateObject("Scripting.FileSystemObject")
Set obj_B = fso.GetFile(TempFile).OpenAsTextStream(1, -2)

ReportToHTML = obj_B.ReadAll

obj_B.Close

Set obj_B = Nothing
Set obj_A = Nothing
Kill str_File

End Function

Nov 12 '05 #2
Lee
Herbert,
Thanks.
Reason I want/need to use a more graphically appealing email look is
to allow the information to be more easily read.

There is information on the report which contains date of request,
date due, date delivered. Then there are memo fields which outline
what is to be delivered, and a few other ones.

In text mode, you can not force/state the font. Therefore, things
don't line up correctly. It gets difficult to provide an easily
readible format.

Hope this helped to answer your question. If not, please feel free to
ask more.
Lee
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485,...
10
by: MLH | last post by:
I print to a device that creates a PDF. Knowing the filename, how can I then embed the PDF into the body text of an OutLook Express outbound email & send to a specified address in a table? I want...
7
by: Susan Bricker | last post by:
I would like to generate a report (I have the report working already) using MS/ACCESS 2000 and then have the ability to send the report as an email attachment to my colleagues. I have looked...
6
by: Anuradha | last post by:
Dear All How can i send mails using vb.net Thanx all
5
by: S.Dickson | last post by:
Hi I hope some one can help, as i am not very good on Access I have built a database for placing orders for customers, On the Order Form i would like a button that would send out a email to...
8
by: Mark | last post by:
Using VB.net 2005, I am trying to send an email with attachments in Outlook. I have tried using this article from Microsoft, (http://support.microsoft.com/?kbid=313803), but I can't even get the...
7
by: Paridevi | last post by:
Hai , i want to send email in .Net Using OutLook Express,My Project is Web Application using vb.Net 2003 with SQL Server 2000.I have searched a lot in Google, but ican't get any...
3
by: jambonjamasb | last post by:
Hi I have two tables: email_tbl Data_table Data table is is used to create a Form Data_form
4
by: kpfunf | last post by:
When I email a report via macro or vba code, the attached report is named "Fuel Quote Report.(ext)". I have no idea how this name is used. I have three seperate macros sending three seperate reports....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.