| Dim s As New NotesSession |
| Dim db As NotesDatabase |
| Dim col As NotesDocumentCollection |
| Dim col1 As NotesDocumentCollection |
| Dim doc As NotesDocument |
| Dim doc1 As NotesDocument |
| Dim view As NotesView |
| Dim item As NotesItem |
| Dim mynotesdir As NotesDirectory |
| Dim uid As String |
| Dim chair As String |
| Dim chairx As String |
| Dim mailinfo As Variant |
| Dim mailsrv As Variant |
| Dim maildb As Variant |
| Dim searchformula As String |
| Dim rtBody As NotesRichTextItem |
| Dim rtBodyTmp As Variant |
| Dim mytext As String |
| Dim tmpName As NotesName |
| Set db=s.CurrentDatabase |
| Set col=db.UnprocessedDocuments |
| Set mynotesdir = s.getDirectory("Server/SRV/Gruppe") |
| mytext = "Dial-In: xxx xxxx xxxx xxx"+Chr(13)+"Room number: xxxx"+Chr(13)+"Pin: xxxx"+Chr(13) |
| |
| On Error GoTo ErrHandler |
| |
| Print "Process Start" |
| Print CStr(col.Count) + " selected documents" |
| Set doc=col.getfirstdocument |
| While Not doc Is Nothing |
| Set item = doc.GetFirstItem( "ResourceName" ) |
| Print "Item=" + item.text |
| If item.text = "Telefonkonferenzraum Geschäftsführung" Then |
| Print "Entry found" |
| ' Hole ApptUNID und Chair und suche dann nach ApptUNID in Mail-DB vom Chair |
| uid = doc.GetItemValue("ApptUNID")(0) ' eindeutige ID des Kalendereintrags |
| Print "uid="+uid |
| chairx = doc.getItemValue("Chair")(0) ' Vorsitzende der Einladung |
| Set tmpName = New NotesName(chairx) ' NotesNamen erzeugen |
| chair = CStr(tmpName.Common) ' Aus NotesNamen nur den Namen lesen |
| Print "Chair="+chair |
| Set mailinfo = mynotesdir.GetMailInfo(chair, True) ' <<<<< hier tritt der Fehler auf |
| Print "test" |
| maildb = CStr(mailinfo(3)) ' Mail-DB des Benutzers |
| mailsrv = CStr(mailinfo(0)) ' Mail-Server des Benutzers |
| Print "Found " + maildb + " on Server " + mailsrv |
| Set db = s.GetDatabase(mailsrv, maildb, False) ' Datenbank öffnen |
| If Not db.IsOpen Then Call db.Open("", "") |
| Set view = db.GetView("Calendar") ' Kalenderview öffnen |
| |
| searchFormula = {ApptUNID = "} + uid + {"} |
| Set col = db.search(searchformula,Nothing,0) ' Nach eindeutiger ID suchen |
| Set doc1 = col1.GetFirstDocument |
| If doc1.ApptUNID = uid Then ' Sicherhaltshalber prüfen, ob das richtige Dokument gefunden wurde |
| Print "Document found" |
| Set rtBody = doc.GetFirstItem("Body") |
| Set rtBodyTmp = doc.CopyItem(rtBody, "Body") ' alten Body zwischenspeichern |
| Call rtBody.remove() ' Body löschen |
| Set rtBody = New NotesRichTextItem(doc, "Body") ' Body neu erstellen |
| Call rtBody.AppendText(myText) ' neuen Text anfügen |
| Call rtBody.AppendRTItem(rtBodyTmp) ' alten Body anfügen |
| Call rtBodyTmp.remove() ' Zwischenspeicher wieder löschen |
| Call doc.Save(True, False, False) |
| Print "Document edited... closing" |
| End If |
| |
| End If |
| Set doc=col.GetNextDocument(doc) |
| Wend |
| Print "Process end" |
| ErrResume: |
| Exit Sub |
| ErrHandler: |
| Print "** Error occured ** " & Str(Err) & ": " & Error$ & " in line " & Str(Erl) & ". Agent stopped." |
| Resume ErrResume |
| |
| |