Mail lesen, kein user doc??

  • Hallo erstmal.


    Ich sag es gleich dass ich kein Notes Profi bin.(falls die Fragen zu einfach sind)
    Also es geht um folgensdes.
    Ich will mittels einen Agenten Neue Emails abfangen und die dann weiter verarbeiten.


    Es klappt alles bis zu dem Schritt wo ich das user doc holen will.
    Am besten schaut ihr euch einfach den Code an.



    Der Rote Text unten ist da wo der Fehler auftritt. (Messagebox "Konnte kein Personendokument finden")


    Ich denke mal es liegt nicht am Code sondern an irgendeiner Einstellung in Notes.


    Ich hoffe jemand kann mir da weiterhelfen.


    ---------------------------------------------------------------------------------------------------------------------------------------------
    %END REM
    Sub Initialize
    Dim Session As New NotesSession
    Dim db As NotesDatabase
    Dim maildb As NotesDatabase
    Dim maildoc As NotesDocument

    Dim ansicht As Notesview

    Dim adrbuchDB As NotesDatabase
    Dim useransicht As NotesView
    Dim userdoc As NotesDocument
    Dim mailfile As String
    Dim myatach As NotesEmbeddedObject
    Dim rtitem As NotesRichTextItem
    On Error Goto Endscript

    Set db = session.CurrentDatabase

    Set adrbuchDB = Session.GetDatabase(db.Server,"names.nsf",False)
    If adrbuchDB Is Nothing Then
    Error 1000
    Else
    [color=FF0000]Set useransicht = adrbuchDB.GetView("($users)")[color=990000]
    Set userdoc = useransicht.GetDocumentByKey( Session.UserName , True )
    If userdoc Is Nothing Then
    Messagebox "Konnte kein [/color] Personendokument finden"[/color] Exit Sub
    Else
    mailfile = userdoc.mailfile(0)
    If mailfile = "" Then
    Messagebox "Sie haben keine MailBox hahaha"
    Exit Sub
    End If
    Messagebox "Mailfile " + mailfile + "Username aus session " + Session.UserName
    End If
    End If

    Set maildb = Session.GetDatabase(db.Server,mailfile,False)

    If maildb Is Nothing Then
    Messagebox "Maildatenbank nicht gefunden!"
    Else
    Set ansicht = maildb.GetView("($inbox)")
    Set maildoc = ansicht.GetFirstDocument

    While Not maildoc Is Nothing
    Messagebox "Das Thema" + maildoc.subject(0)

    Set rtitem = maildoc.GetFirstItem( "Body" )
    If ( rtitem.Type = RICHTEXT ) Then
    If Not Isempty(rtitem.EmbeddedObjects) Then
    Forall o In rtitem.EmbeddedObjects
    If ( o.Type = EMBED_ATTACHMENT ) Then
    Messagebox( "Attatschemnet da! "+o.Name )
    End If
    End Forall
    End If
    End If

    Set maildoc = ansicht.GetNextDocument(maildoc)
    Wend

    End If

    Ende:
    Exit Sub
    Endscript:
    Select Case Err
    Case 1000: Messagebox "Zugriff auf Adressbuch fehlgeschlagen"
    Case 3000: Messagebox "Eigenproduktion"
    Case 4060: Messagebox "emememe"
    Case Else
    Messagebox "Fehler man " + Error + " Zeile: " + Cstr(Erl)+ " Nummer: "+Cstr(Err)
    End Select
    Resume Ende
    End Sub
    ---------------------------------------------------------------------------------------------------------------------------------------------------------

  • Wenn man sich die View ansieht erkennt man, dass mit @LowerCase gearbeitet wird. Ergo: Um Session.UserName noch ein Lower LCase drumherum und gut ist...

    Life is not a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming "Wow, what a ride!!! :evil:
    Beschleunigung ist, wenn die Tränen der Ergriffenheit waagrecht zum Ohr hin abfliessen - Walter Röhrl

  • Du arbeitest aber nicht zufälligerweise auf einer lokalen Replik? Dann wäre db.Server = "" und denn kann das nicht funktionieren...

    Life is not a journey to the grave with the intention of arriving safely in a pretty and well-preserved body, but rather to skid in broadside, thoroughly used up, totally worn out, and loudly proclaiming "Wow, what a ride!!! :evil:
    Beschleunigung ist, wenn die Tränen der Ergriffenheit waagrecht zum Ohr hin abfliessen - Walter Röhrl

  • Wird der Agent zufälligerweise periodisch oder ereignisgesteuert ausgeführt ?


    Denn dieser Code findet nur dann das passende Personendokument wenn er manuell ausgeführt wird.


    Siehe Hilfe:


    Zitat


    Read-only. The current user's name.
    For a script running on a workstation, this is the name of the current user.
    For a script running on a server, this is the name of the server.