Hi I,m trying to utilise some code below which was posted here in 2002 which if I can get it to work will do just what I want, my problem is that when I run it the first part works fine, creates the report but when running on fails with "Object variable or with block not set"
Dont know why wonder if anyone can advise me?
=====================================================
Function email2delivery_email()
On Error GoTo email2delivery_email_Err
Dim strline, strHTML
Dim MyItem As Outlook.MailItem
Dim OL As New Outlook.Application
DoCmd.OutputTo acOutputReport, "Bulk Report", acFormatRTF, "C:\Bulk Report.rtf", False
Open "C:\Bulk Report.rtf" For Input As 1
Do While Not EOF(1)
Input #1, strline
strHTML = strHTML & strline
Loop
Close 1
' If OL2002 set the BodyFormat
If Left(OL.Version, 2) = "10" Then
MyItem.BodyFormat = olFormatHTML
End If
MyItem.HTMLBody = strHTML
MyItem.Display
email2delivery_email_Exit:
Exit Function
email2delivery_email_Err:
MsgBox Error$
Resume email2delivery_email_Exit
End Function
Dont know why wonder if anyone can advise me?
=====================================================
Function email2delivery_email()
On Error GoTo email2delivery_email_Err
Dim strline, strHTML
Dim MyItem As Outlook.MailItem
Dim OL As New Outlook.Application
DoCmd.OutputTo acOutputReport, "Bulk Report", acFormatRTF, "C:\Bulk Report.rtf", False
Open "C:\Bulk Report.rtf" For Input As 1
Do While Not EOF(1)
Input #1, strline
strHTML = strHTML & strline
Loop
Close 1
' If OL2002 set the BodyFormat
If Left(OL.Version, 2) = "10" Then
MyItem.BodyFormat = olFormatHTML
End If
MyItem.HTMLBody = strHTML
MyItem.Display
email2delivery_email_Exit:
Exit Function
email2delivery_email_Err:
MsgBox Error$
Resume email2delivery_email_Exit
End Function