I think I’ve read every post on the subject but I’ve yet to find a solution. I’m trying to send email via SMTP using CDO (CDOSYS) on our Win2000 server. I can schedule the document to refresh with BCA and it creates the HTML file beautifully, but I haven’t read anything that points me in the right direction on my error message. Can anyone shed some light as I am stuck like Chuck - thanks
I get the following error:
“Error in procedure Document_AfterRefresh – 3749: Fields update failed. For further information, examine the Status property of individual field objects. (ADODB.Fields)”
Here’s the code:
Private Sub Document_AfterRefresh()
Const OUTPUT_DIRECTORY As String = "D:\BOTest"
Const ERR_MSG_PATH As String = "D:\BOTest\ErrorLogs"
Dim DocOpen As Integer
Dim Docname As String
Dim doc As IDocument
Dim rpt As Report
Dim SavHtmname As String
DocOpen = 1
LogOpen = 0
On Error GoTo ErrHandler
Set doc = ActiveDocument
Set rpt = ActiveReport
Docname = ActiveDocument.Name
'Export HTML file
SavHtmname = OUTPUT_DIRECTORY & "\" & Docname & ".htm"
Call rpt.ExportAsHtml(SavHtmname, 1, 1, 1, 1, 1, 1, 1, 0, 0)
Dim iMsg
Dim iConf
Const cdoSendUsingPort = 25
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "<10.0.1.10>"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update ' <------ My problem is here but not sure why.
End With
'Send email with attachment
With iMsg
Set .Configuration = iConf
.To = "me@company.com"
.From = "me@company.com"
.Subject = "an example mhtml formatted message"
.AddAttachment SavHtmname
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
ForceExit:
Exit Sub
ErrHandler:
'******
lngFileNum = FreeFile()
strLogFileName = ERR_MSG_PATH & "\" & ActiveDocument.Name & "-ErrorMessages.Log"
strLogMsg = "Error in procedure Document_AfterRefresh -- " & Err.Number & ": " _
& Err.Description & " (" & Err.Source & ")"
Open strLogFileName For Append As #lngFileNum
Write #lngFileNum, Now(), strLogMsg
Close #lngFileNum
'*** This "Resume" statement resets the error and allows your procedure to exit cleanly.
Resume ForceExit
'******
End Sub
[Edit - Please use the “Code” formatting option when posting code samples. It preserves the indenting and makes the post easier to read. Thanks. - Dave]
SeanB (BOB member since 2004-02-11)