Servus,
ich muss Emails aus einer Maildatenbank in einer andere verschieben. Es müssen alle Daten erhalten bleiben. Jetzt hab ich mal ein kleines Skript geschrieben, jedoch taucht die Mail in der Ziel-DB nicht auf. Vielleicht fällt ja jemanden der Fehler auf und könnt mir weiterhelfen.
Sub Initialize
Dim session As New NotesSession
Dim allsrcdoc As NotesDocumentCollection
Dim tgtdbname As String
Dim srcdb, tgtdb As NotesDatabase
Dim srcdoc As NotesDocument
Set srcdb = session.CurrentDatabase
Set allsrcdoc = srcdb.UnprocessedDocuments
If allsrcdoc.Count < 1 Then
Messagebox "No document selected.", 16, "Information"
Exit Sub
End If
tgtdbname ="testdb.nsf"
Set tgtdb = New NotesDatabase("",tgtdbname)
If tgtdb.IsOpen = False Then
Messagebox "Target Database not found", 16, "Information"
Exit Sub
End If
Set srcdoc = allsrcdoc.GetFirstDocument
While Not (srcdoc Is Nothing)
Dim newdoc As NotesDocument
Set newdoc = New NotesDocument (tgtdb)
Call srcdoc.copyallitems(newdoc,True)
newdoc.save True, True, True
Set srcdoc = allsrcdoc.GetNextDocument(srcdoc)
Wend
End Sub
gruss
Michael
Ja, die Anzahl erhöht sich. Den Code habe ich auch angepasst, dass das Dokument in den Folder geschoben wird. Geht dies mit dem PutInFolder so?
While Not (srcdoc Is Nothing)
Dim newdoc As NotesDocument
Set newdoc = New NotesDocument (tgtdb)
Call srcdoc.copyallitems(newdoc,True)
Call newdoc.PutInFolder("CRM\Inbound Mail")
Call newdoc.Save(True, True, True)
Set srcdoc = allsrcdoc.GetNextDocument(srcdoc)
Wend