Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

report in email body multipage.

Status
Not open for further replies.

mercurialfire

IS-IT--Management
Nov 15, 2006
5
GB
Hi.
I want to generate a email with the results of a report in msacess.
I export this report in a HTML email, but if the reports contain more than one page, the resultant HTML points the other pages with an hipervincle and fails.

Can I export via HTLM generating one large page?

Thanks in advance and sorry for mi poor english
 
I have not tried it, but I think RTF should work.
 
I try with RTF but in the body appear the code of RTF. I can´t format in Outlook the message exported via RTF.

Thanks!!
 
Well, you could mess with the pages:

Code:
Sub HTMBodyX()
Const ForReading = 1, ForWriting = 2, ForAppending = 3

Dim fs, f, i
Dim strBody As String, strHTMBody As String
Dim olApp As New Outlook.Application
Dim olItem As Outlook.MailItem

Dim strPath As String
Dim strOutDoc As String, strOutDocX As String
Dim strExt As String
Dim strReport As String
Dim intPages As Integer

strPath = "C:\Docs\"
strOutDoc = "rptReport"
strExt = ".htm"
strReport = "rptReport"

DoCmd.OpenReport strReport, acViewPreview
intPages = Reports(strReport).Pages
DoCmd.Close acReport, strReport
DoCmd.OutputTo acOutputReport, strReport, acFormatHTML, strPath & strOutDoc & strExt

Set fs = CreateObject("Scripting.FileSystemObject")

For i = 1 To intPages
    If i = 1 Then
        strOutDocX = strOutDoc & strExt
    Else
        strOutDocX = strOutDoc & "Page" & i & strExt
    End If
    
    Set f = fs.OpenTextFile(strPath & strOutDocX, ForReading)
    strBody = f.ReadAll
    If i < intPages Then
        strBody = Mid(strBody, 1, InStr(strBody, "<A HREF=""#"">First</A>") - 1)
    End If
    If i > 1 Then
        strHTMBody = strHTMBody & "</P><P></P><P>" & strBody
    Else
        strHTMBody = strBody
    End If
    
    f.Close
Next

Set olItem = olApp.CreateItem(olMailItem)
With olItem
   .To = "a@b.c"
   .Subject = "Subject Line"
   .HTMLBody = strHTMBody
   .Display
End With
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top