Das Notes Forum
Domino 9 und frühere Versionen => ND6: Entwicklung => Thema gestartet von: Holger am 17.05.05 - 01:32:25
-
Hallo
Ich habe gerade eine neue Datenbank entwickelt, die Angebotsdokumente verwaltet. Die User sollen sich in dieser Db über einen Newsletter über neue Dokumente die Sie interessieren informieren lassen können. Ich habe dazu den bestehenden Newsletter aus der Diskussion DB genommen und in meine DB mit eingebaut. Wenn ich nun aber den Newsletter laufen lassen, dann läuft er zwar bis zum Ende aber sendet keine Mail an den User. Ich habe dann den Debugger eingesetzt und festgestellt, dass der Agent immer an der folgenden Stelle abbricht und zum Error Teil übergeht:
==> ab hier springt der Debugger zum error Clenaup!
Set newnote = newsletter.FormatMsgWithDoclinks(db)
newnote.Form = "Memo"
newnote.SendTo = pPersonName(0)
newnote.SendTo = pSendTo(0)
newnote.Subject = getstring(33) & db.Title
newnote.Send False
End If
End If
ErrorReset:
Set profile = view.GetNextDocument(profile)
Loop
Exit Sub
ErrorCleanup:
If Err = 4294 Or Err = 4295 Then
Goto ErrorReset
Ich verstehe nicht, was ich falsch gemacht habe, bzw. warum er hier abbricht? Kann mir jemand bei diesem Problem weiterhelfen?
Danke
Holger
-
Dazu muesste man sehen, was vor dem "==> ab hier springt der Debugger zum error Clenaup!" steht.
-
Habe jetzt einfach mal den gesamten Agent eingefügt, vielleicht ist es dann einfacher. Danke
'Send Newsletters | Send Newsletters:
Use "wStringResource"
'Send Newsletters | Send Newsletters:
Dim s As NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim note As NotesDocument
Dim profile As NotesDocument
Dim newnote As NotesDocument
Dim newsletter As NotesNewsLetter
Dim collection As NotesDocumentCollection
Dim pPersonName As Variant
Dim pCategories As Variant
Dim pEvents As Variant
Dim pAuthors As Variant
Dim pStrings As Variant
Dim pMyName As Variant
Dim pThreads As Variant
Dim searchtype As String
Dim query As String
Dim textlist As String
Dim totalquery As String
Dim failed As Integer
Dim abrAltFrom As Variant
Sub Initialize
On Error Goto ErrorCleanup
Set s = New NotesSession
Set db = s.CurrentDatabase
Set view = db.GetView("($Profiles)")
Set profile = view.GetFirstDocument
If profile Is Nothing Then Exit Sub
Failed = False
FormName = profile.Form
If FormName(0) <> "Interest Profile" Then Set profile = view.GetNextDocument(profile)
Do Until profile Is Nothing
FormName = profile.Form
pPersonName = profile.PersonName
pSendTo = profile.FullPersonName
pCategories = profile.ProfileCategories
' pEvents = profile.ProfileEvents
pAuthors = profile.ProfileAuthors
pStrings = profile.ProfileStrings
pMyName = profile.ProfileMyName
pThreads = profile.ProfileThreads
If pCategories(0) = "" And pAuthors(0) = "" And pStrings(0) = "" And pMyName(0) = "" And pThreads(0) = "" Then
'if all the fields are blank, don't bother to search
Else
If db.IsFTIndexed = True Then
DoFTSearch
Else
DoFormulaSearch
End If
If collection.Count > 0 Then
Set newsletter = New NotesNewsletter(collection)
newsletter.DoSubject = True
newsletter.SubjectItemName = "NewsLetterSubject"
Set newnote = newsletter.FormatMsgWithDoclinks(db)
newnote.Form = "Memo"
newnote.SendTo = pPersonName(0)
newnote.SendTo = pSendTo(0)
newnote.Subject = getstring(33) & db.Title
newnote.Send False
End If
End If
ErrorReset:
Set profile = view.GetNextDocument(profile)
Loop
Exit Sub
ErrorCleanup:
If Err = 4294 Or Err = 4295 Then
Goto ErrorReset
Else
Failed = True
Exit Sub
End If
End Sub
Sub DoFTSearch
searchtype = "FT"
totalquery = ""
Forall n In pCategories
BuildTextList(n)
End Forall
If textlist <> "" Then
query = "field Categories contains (" & textlist & ")"
BuildTotalQuery
End If
Forall n In pAuthors
BuildTextList(n)
If textlist <> "" Then
query = "field AbbreviateFrom contains " & textlist & " Or field AltFrom contains " & textlist
BuildTotalQuery
End If
End Forall
Forall n In pStrings
BuildTextList(n)
End Forall
If pMyName(0) <> "" Then
Forall n In pPersonName
BuildTextList(n)
End Forall
End If
If textlist <> "" Then
query = "field Body contains (" & textlist & ") or field Subject contains (" & textlist & ")"
BuildTotalQuery
End If
Forall n In pThreads
BuildTextList(n)
End Forall
If textlist <> "" Then
query = "field ThreadId contains (" & textlist & ")"
BuildTotalQuery
End If
totalquery = totalquery & " and (not(field form contains log, profile))"
Set collection = db.UnprocessedFTSearch(totalquery, 0)
End Sub
Sub DoFormulaSearch
searchtype = "Formula"
totalquery = ""
If pCategories(0) <> "" Then
Forall n In pCategories
BuildTextList(n)
End Forall
If textlist <> "" Then
query = "(@Contains(@UpperCase(Categories); @UpperCase(" & textlist &_
")) | @AllDescendants)"
BuildTotalQuery
End If
End If
If pAuthors(0) <> "" Then
Forall n In pAuthors
BuildTextList(n)
End Forall
If textlist <> "" Then
query = "@Contains(@UpperCase(AbbreviateFrom); @UpperCase(" & textlist & ")) | @Contains(@UpperCase(AltFrom); @UpperCase(" & textlist & "))"
BuildTotalQuery
End If
End If
If pStrings(0) <> "" Then
Forall n In pStrings
BuildTextList(n)
End Forall
If textlist <> "" Then
query = "@Contains(@UpperCase(Body); @UpperCase(" & textlist &_
")) | @Contains(@UpperCase(Subject); @UpperCase(" & textlist & "))"
BuildTotalQuery
End If
End If
If pMyName(0) <> "" Then
query = "@Contains(@UpperCase(Body); @UpperCase(" & """" & pPersonName(0) & """" &_
")) | @Contains(@UpperCase(Subject); @UpperCase(" & """" & pPersonName(0) & """" & "))"
BuildTotalQuery
End If
If pThreads(0) <> "" Then
Forall n In pThreads
BuildTextList(n)
End Forall
If textlist <> "" Then
query = "@Contains(@UpperCase(ThreadId); @UpperCase(" & textlist & "))"
BuildTotalQuery
End If
End If
totalquery = totalquery & " & @isavailable(NewsletterSubject) & (!@Contains(Form; ""Log"" : ""Profile"")) & (readers = """")"
Set collection = db.UnprocessedSearch(totalquery, Nothing, 0)
End Sub
Sub BuildTextList(n As Variant)
If searchtype = "FT" Then
If textlist = "" Then
textlist = n
Else
textlist = textlist & ", " & n
End If
Else
nvalue = """" & n & """"
If textlist = "" Then
textlist = nvalue
Else
textlist = textlist & " : " & nvalue
End If
End If
End Sub
Sub BuildTotalQuery
If totalquery = "" Then
totalquery = query
Else
If searchtype = "FT" Then
totalquery = totalquery & " or " & query
Else
totalquery = totalquery & " | " & query
End If
query = ""
End If
textlist = ""
End Sub
Sub Terminate
If Not (failed) Then
Set collection = db.UnprocessedDocuments
For n = 0 To collection.Count
Set note = collection.GetNthDocument(n)
Call s.UpdateProcessedDoc(note)
Next
End If
End Sub
-
Und mit welcher Fehlermeldung bricht er ab?
-
Hi, es gibt keine Fehlermeldung, er überspringt einfach zu dem Punkt :
ErrorCleanup:
If Err = 4294 Or Err = 4295 Then
Goto ErrorReset
und bearbeitet aber die eigentliche Mailsend Funktion ab dem Punkt :
Set newnote = newsletter.FormatMsgWithDoclinks(db)
newnote.Form = "Memo"
newnote.SendTo = pPersonName(0)
newnote.SendTo = pSendTo(0)
newnote.Subject = getstring(33) & db.Title
newnote.Send False
End If
End If
ErrorReset:
Set profile = view.GetNextDocument(profile)
Loop
Exit Sub
nicht mehr. Wenn ich das richtig verstehe würde er ja in diesem Bereich das Mail Memo fertig machen. Wie gesagt er bringt keine Fehlermeldung sonder springt einfach auf den error Bereich weiter sobald er bei "Set newnote = newsletter.FormatMsgWithDoclinks(db)" ankommt.
-
Hi,
wenn du ein eigenes Errorhandling en baust, dann musst du auch dafür sorgen, dass alle Fehlermeldungen angezeigt werden.
Erweitere deine Fehlerbehandlung mal wie folgt:
ErrorCleanup:
If Err = 4294 Or Err = 4295 Then
Goto ErrorReset
Else
Messagebox "Bei der Verarbeitung ist ein Fehler aufgetreten." & Chr$(13) & _
"Fehler-Nr.: " & Str(Err) & " : " & Error$ & " in Zeile " & Str(Erl), 16, "Fehler"
Exit Sub
End If
Dann solltest du den Fehler angezeigt bekommen.
Axel
PS:
Zum Thema Error-Handling gibt es in Best Pratices-Forum auch einen guten Artikel:
Best Practices: Error Handling in Lotus Script: Einleitung (http://www.atnotes.de/index.php?topic=11980.0)
-
Hi, Axel Danke für die Antwort, bin absoluter newbie mit dem ganzen Script Thema, habe Deinen Input eingebaut und auch eine Fehlermeldung bekommen aber jetzt steh ich noch mehr auf dem Schlauch und weiß überhaupt nicht mehr was denn jetzt falsch daran ist.
Fehler Nr. 4005:Notes Error: Special Database Object cannot be located (FinalTestSales.nsf) in Zeile 38.
Zeile 38 währe meiner Meinung nach wieder die Zeile:
Set newnote = newsletter.FormatMsgWithDoclinks(db)
Aber warum bringt er hier einen Fehler?
Danke
-
Hi,
hast du in deiner Datenbank eine Vorgabeansicht definiert?
Axel
-
Super, konnte das Problem lösen, danke für die Hilfe
-
Hi,
prima, aber lässt du uns an deiner Lösung teilhaben. Vielleicht steht ein anderer mal vor dem gleichen Problem und kann dann von deiner Lösung profitieren.
Danke.
Axel