Notes: Wenn im Posteingang Mails fehlen…

Dieser Agent kann in einer Notes MailDB verwendet werden, wenn Emails im Posteingang fehlen und die Dokumente aber unter Alle Dokumente zu sehen sind.

Man erzeugt einen neuen Agenten, gibt im einen Namen und speichert ihn. Danach kann man in den AllDocuments View gehen und über das Aktionen Menü den Agenten starten.
ACHTUNG!!! Der Vorgang kann bei sehr vollen DBs sehr lange laufen.

%REM
Agent Eingang aufräumen
Created Dec 22, 2016 by Markus Pooch/solvito
Description: Falls mal die Dokumente im Posteingang weg sind.
%END REM
Option Public
Option Declare

Sub Initialize<
Dim s As New NotesSession
Dim db As NotesDatabase
Dim fDoc As NotesDocument ' Document in folder
Dim ad As NotesView ' All Documents view
Dim aDoc As NotesDocument ' document in All Docs view
Dim deldate As NotesItem
Dim postdate As NotesItem
Dim Chair1 As NotesItem
Dim cnt As Long
Set db = s.CurrentDatabase
' Loop through docs in the All Documents view and move into $Inbox
Set ad = db.GetView("($All)")
Set aDoc = ad.GetFirstDocument
cnt = 0
While Not aDoc Is Nothing
Set deldate = adoc.getfirstitem("DeliveredDate")
Set postdate = adoc.GetFirstItem("PostedDate")
Set Chair1 = adoc.getfirstitem("CHAIR")
If (Not (deldate Is Nothing) Or (postdate Is Nothing And Not (deldate Is Nothing))) And (Chair1 Is Nothing) Then
Call adoc.PutInFolder( "($Inbox)")
cnt = cnt + 1
End If
Set aDoc = ad.GetNextDocument(adoc)
Wend
Print Str(cnt)+" mails put into the Inbox"
' Remove documents from $Inbox which are in folders already
' by looping through folders, then their documents
ForAll view In db.views
If view.IsFolder And Not view.Name=("($All)") And Not view.Name=("($Inbox)") And Not view.Name=("($Sent)") Then
Set fDoc = view.GetFirstDocument
While Not fDoc Is Nothing
Call fdoc.RemoveFromFolder("($Inbox)")
cnt = cnt -1
Set fDoc = view.GetNextDocument(fDoc)
Wend
End If
End ForAll
Print Str(cnt)+" mails remained in the Inbox"
End Sub

 

 

Schreibe einen Kommentar