S
SZito
I have a function that runs at Startup and if at a certain time it is supposed to send an email. It has worked fine until this week. All of the sudden I get Error 2046 "OutputTo not available". The thing is that it still runs fine on an older version of the database, but there haven't been any chages the code itself or the reports its supposed to output. Any suggestions would be greatly appreciated, here is the code I am using:
Option Compare Database
Option Explicit
______________________________
Public Function EmailFollowUp()
Dim StartTime As String
Dim olapp As Outlook.Application
Dim olmail As Outlook.MailItem
Dim strto As String
Dim strSubject As String
Dim strattach As String
Dim strrptName As String
Dim strrptfile As String
StartTime = "11:35 PM"
If WeekDay(Now(), vbMonday) < 5 Then
If Format(Now(), "Medium time") = Format(StartTime, "Medium time") Then
Dim olapp As Outlook.Application
Dim olmail As Outlook.MailItem
Dim strto As String
Dim strSubject As String
Dim strattach As String
Dim strrptName As String
Dim strrptfile As String
strrptName = "rptFollowUp"
strrptfile = "F:\Databases\snpReports\rptFollowUp.snp"
strto = "steve.zito@seagatetravel"
strSubject = "Customer Service Follow Up Report"
strattach = strrptfile
DoCmd.OutputTo acOutputReport, strrptName, _
acFormatSNP, strrptfile, False
Set olapp = CreateObject("Outlook.Application")
Set olmail = olapp.CreateItem(olMailItem)
olmail.To = strto
olmail.Subject = strSubject
olmail.Attachments.Add (strattach)
olmail.Send
DoCmd.Quit acQuitSaveAll
Else
DoCmd.OpenForm "frmCSDATA"
End If
ElseIf WeekDay(Now(), vbMonday) = 5 Then
If Format(Now(), "Medium time") = Format(StartTime, "Medium time") Then
strrptName = "rptFollowUpfri"
strrptfile = "F:\Databases\snpReports\rptFollowUp.snp"
strto = "(e-mail address removed)"
strSubject = "Customer Service Follow Up Report"
strattach = strrptfile
DoCmd.OutputTo acOutputReport, strrptName, _
acFormatSNP, strrptfile, False
Set olapp = CreateObject("Outlook.Application")
Set olmail = olapp.CreateItem(olMailItem)
olmail.To = strto
olmail.Subject = strSubject
olmail.Attachments.Add (strattach)
olmail.Send
DoCmd.Quit acQuitSaveAll
Else
DoCmd.OpenForm "frmCSDATA"
End If
Else
DoCmd.OpenForm "frmCSDATA"
End If
End Function
Option Compare Database
Option Explicit
______________________________
Public Function EmailFollowUp()
Dim StartTime As String
Dim olapp As Outlook.Application
Dim olmail As Outlook.MailItem
Dim strto As String
Dim strSubject As String
Dim strattach As String
Dim strrptName As String
Dim strrptfile As String
StartTime = "11:35 PM"
If WeekDay(Now(), vbMonday) < 5 Then
If Format(Now(), "Medium time") = Format(StartTime, "Medium time") Then
Dim olapp As Outlook.Application
Dim olmail As Outlook.MailItem
Dim strto As String
Dim strSubject As String
Dim strattach As String
Dim strrptName As String
Dim strrptfile As String
strrptName = "rptFollowUp"
strrptfile = "F:\Databases\snpReports\rptFollowUp.snp"
strto = "steve.zito@seagatetravel"
strSubject = "Customer Service Follow Up Report"
strattach = strrptfile
DoCmd.OutputTo acOutputReport, strrptName, _
acFormatSNP, strrptfile, False
Set olapp = CreateObject("Outlook.Application")
Set olmail = olapp.CreateItem(olMailItem)
olmail.To = strto
olmail.Subject = strSubject
olmail.Attachments.Add (strattach)
olmail.Send
DoCmd.Quit acQuitSaveAll
Else
DoCmd.OpenForm "frmCSDATA"
End If
ElseIf WeekDay(Now(), vbMonday) = 5 Then
If Format(Now(), "Medium time") = Format(StartTime, "Medium time") Then
strrptName = "rptFollowUpfri"
strrptfile = "F:\Databases\snpReports\rptFollowUp.snp"
strto = "(e-mail address removed)"
strSubject = "Customer Service Follow Up Report"
strattach = strrptfile
DoCmd.OutputTo acOutputReport, strrptName, _
acFormatSNP, strrptfile, False
Set olapp = CreateObject("Outlook.Application")
Set olmail = olapp.CreateItem(olMailItem)
olmail.To = strto
olmail.Subject = strSubject
olmail.Attachments.Add (strattach)
olmail.Send
DoCmd.Quit acQuitSaveAll
Else
DoCmd.OpenForm "frmCSDATA"
End If
Else
DoCmd.OpenForm "frmCSDATA"
End If
End Function