C
cyb3rwolf
Hello. I have a form where i have a button set up to send the contents of a
report in the body of an e-mail. The problem i run into is that if the
report is more than one page, it will only show the first page in the body of
an e-mail with links to the other pages at the bottom of the e-mail, which
cannot be accessed. Is there a way to code it where the whole report would
be one page to solve my little problem? Here is the code i currently have:
Public Sub olSendRpt(strTo As String, strBody As String, strSubject As
String, strReportName As String)
Dim strFileName As String, intFile As Integer, strLine As String,
strTemplate As String
Dim objOutlk 'Outlook
Dim objMail 'Email item
Dim strMsg
strFileName = Environ("Temp") & "\rep_temp.html"
If Len(Dir(strFileName)) > 0 Then
Kill strFileName
End If
DoCmd.OutputTo acOutputReport, strReportName, acFormatHTML, strFileName
intFile = FreeFile
Open strFileName For Input As #intFile
Do While Not EOF(intFile)
Line Input #intFile, strLine
strTemplate = strTemplate & vbCrLf & strLine
Loop
Close #intFile
strMsg = strTemplate
Set objOutlk = CreateObject("Outlook.Application")
Set objMail = objOutlk.createitem(olMailItem)
objMail.To = strTo
objMail.CC = ""
objMail.subject = strSubject
objMail.HTMLbody = strMsg
objMail.Display
Set objMail = Nothing
Set objOutlk = Nothing
End Sub
report in the body of an e-mail. The problem i run into is that if the
report is more than one page, it will only show the first page in the body of
an e-mail with links to the other pages at the bottom of the e-mail, which
cannot be accessed. Is there a way to code it where the whole report would
be one page to solve my little problem? Here is the code i currently have:
Public Sub olSendRpt(strTo As String, strBody As String, strSubject As
String, strReportName As String)
Dim strFileName As String, intFile As Integer, strLine As String,
strTemplate As String
Dim objOutlk 'Outlook
Dim objMail 'Email item
Dim strMsg
strFileName = Environ("Temp") & "\rep_temp.html"
If Len(Dir(strFileName)) > 0 Then
Kill strFileName
End If
DoCmd.OutputTo acOutputReport, strReportName, acFormatHTML, strFileName
intFile = FreeFile
Open strFileName For Input As #intFile
Do While Not EOF(intFile)
Line Input #intFile, strLine
strTemplate = strTemplate & vbCrLf & strLine
Loop
Close #intFile
strMsg = strTemplate
Set objOutlk = CreateObject("Outlook.Application")
Set objMail = objOutlk.createitem(olMailItem)
objMail.To = strTo
objMail.CC = ""
objMail.subject = strSubject
objMail.HTMLbody = strMsg
objMail.Display
Set objMail = Nothing
Set objOutlk = Nothing
End Sub