Personally, I am with the following problem:I have an application on the server and the mail databases on ServerB.
Theoretically (according to the administrator) the servers communicate over the network without problems.
No Application serverA road the following agent:
Sub Initialize
On Error Goto Errhandle
Dim ss As New notessession
Dim db As notesdatabase
Dim dc As notesdocumentcollection
Dim doc As notesdocument
Dim dcmail As NotesDocumentCollection
Dim docmail As NotesDocument
Dim viewmail As notesview
Dim prefixo As String
Dim view As notesview
Dim view2 As NotesView
Dim dc2 As NotesDocumentCollection
Dim x As Integer
Dim item As NotesItem
Dim tag As String
Dim ItemMail As NotesItem
’
Print “Pepara ambiente”
’
Print "NFe\DesanexaXML - Início, às: " & Now
Set db=ss.currentdatabase
Set view = db.getview(“(FORMS)”)
Set view2 = db.GetView(“(FILES)”)
’
'Verifica Perfis
’
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument()
While Not doc Is Nothing
If doc.ativo(0)<>“1” Then Goto proximo_perfil 'Verifica se perfil esta ativado.
’
'Com base no perfil, pega base de email
’
Dim dbmail As New NotesDatabase(doc.F01Server(0) , doc.F01PathMail(0) )
tag = doc.F01Unidade(0)
Set viewmail = dbmail.GetView(“($All)”)
Set docmail = viewmail.GetFirstDocument()
While Not docmail Is Nothing
If docmail.Form(0) <> “Memo” Then Goto proximo_email
If docmail.xmlFlag(0) = “1” Then Goto proximo_email
Dim rtitem As Variant
Set rtitem = docmail.GetFirstItem( “Body”)
'testa a presença de anexos
res=Evaluate(“@Attachments”,docmail)
If res(0)>0 Then
Forall o In rtitem.EmbeddedObjects
file$ = o.name
file$ = ReplaceSubstring (file$,“",”")
file$ = ReplaceSubstring (file$,“:”,“”)
file$ = ReplaceSubstring (file$,“/”,“”)
prefixo = Strright(file$,“.”)
If prefixo = “xml” Then 'se anexo for xml, salva o arquivo
path$=doc.F01LocalPath(0) & file$
Call o.ExtractFile( path$ )
Print "XML: " & path$
Call CriaDOC(path$, tag)
Kill path$
'marca email como lido
Set ItemMail = docmail.AppendItemValue( “xmlFlag”, “1” )
Call docmail.save (True, False)
End If
End Forall
End If
proximo_email:
Set docmail=viewmail.getnextdocument(docmail)
Wend
proximo_perfil:
Set doc = dc.GetNextDocument(doc)
Wend
Exit Sub
Errhandle:
body = “Erro " & Err & “-” & Error & " , na linha " & Erl & " no arquivo " & path$ & " - DesanexaXMLmn”
Print body
Goto proximo_email
End Sub
What makes this agent:
Get all the emails ServerB, detaches the XML files, extracts the data from xml and creates a new doc on the server, with data that were more exta xml attached.
It turns out that this agent is only run manually when scheduler error in the following line:
Sep ViewMail dbmail.GetView = ( “($ All)”), the error message that is written to the log server:
03/12/2010 11:45:48 AM ASBT: Agent ( ‘DesanexaXML’ in ‘xxx \ xx \ NFe.nsf’) printing: 4063-Database error xpto.com / foo! Mailwimk1816 \ \ nfiscal9742.nsf has not been opened yet, the line 38 in file - DesanexaXML