vb@rchiv
VB Classic
VB.NET
ADO.NET
VBA
C#
Erstellen von dynamischen Kontextmen?s - wann immer Sie sie brauchen!  
 vb@rchiv Quick-Search: Suche startenErweiterte Suche starten   Impressum  | Datenschutz  | vb@rchiv CD Vol.6  | Shop Copyright ©2000-2025
 
zurück

 Sie sind aktuell nicht angemeldet.Funktionen: Einloggen  |  Neu registrieren  |  Suchen

Fortgeschrittene Programmierung
Exchange Anbindung mit VB 
Autor: MartinAmmerschuber
Datum: 13.05.05 10:08

Hallo,
ich habe ein kleines Programm, was mir den Inhalt einer Inbox anzeigen soll. Eigentlich sollte das ganze ja gar nicht so schwer sein, aber ich bekomme beim Befehl "GetInterface" kein sauberes Objekt zurück. n meinen Objekteigenschaften steht dann immer "Ungültige Klassenzeichenfolge". Was mache ich falsch ? Ich bin absolut am Ende mit meinem Latein...

Hier ist der verwendete Code:
Sub GetInboxMessages()
    'Set Error Handling
    On Error GoTo Fehler
 
' Create a CDOEX Person object. This will be used to determine
' the URL of the user's Inbox.
 
    Dim iPerson As New CDO.Person
 
' Create an ADO Recordset object. This will be used to
' hold the message items that are in the users Inbox.
 
    Dim rstInbox As New ADODB.Recordset
 
' Create an ADO Connection object. This will be used to
' make a connection to the Exchange Store using the
' the EXOLEDB data provider.
 
    Dim conInbox As New ADODB.Connection
 
' Create a mailbox interface. This will be used to get the
' user's Inbox URL.
 
    Dim iMailbox As CDO.iMailbox ' iMailbox
 
    Dim strEmail As String
    Dim strInboxQuery As String
 
    strEmail = "mailto:" & strEmailAddress
 
' Get data for the Person object. This will be used to get
' the users Inbox url.
 
    iPerson.DataSource.Open strEmail
 
    If Err.Number <> 0 Then
        MsgBox "Error opening mailbox.  Did you enter a valid e-mail address?"
        Exit Sub
    End If
 
' Get the Mailbox interface from the Person object for the
' user.
 
    Set iMailbox = iPerson.GetInterface("IMailbox")
    MsgBox (iMailbox.Inbox)
 
' Set up a query to get all the items in the user's Inbox
' that are not hidden or a folder.
 
    strInboxQuery = "select " & """DAV:href""" & "from scope('shallow traversal" & _
      "of """ & iMailbox.Inbox & """')" & "where ""DAV:ishidden"" = false and" _
      & "      ""DAV:isfolder"" = false"
 
' Set the ADO Connection object properties to open the
' user's Inbox.
 
    With conInbox
        .Provider = "exoledb.datasource"
        .Open iMailbox.Inbox
    End With
 
' Use the ADO Connection object and the Query mentioned
' above to get the items that are located in the user's
' Inbox.
 
    rstInbox.Open strInboxQuery, conInbox
 
    If rstInbox.RecordCount = 0 Then
        lstInbox.AddItem "No items in Inbox!"
        btnReply.Enabled = False
        btnForward.Enabled = False
        lblInboxFrom.Caption = ""
        lblInboxSubject.Caption = ""
        lblInboxBody.Caption = ""
    Else
        While Not rstInbox.EOF
            lstInbox.AddItem rstInbox(0)
            rstInbox.MoveNext
        Wend
    End If
 
    rstInbox.Close
 
    ' Clean up.
    Set rstInbox = Nothing
    Set iPerson = Nothing
    Set conInbox = Nothing
    Set iMailbox = Nothing
 
    btnForward.Enabled = False
    btnReply.Enabled = False
    Exit Sub
    Resume
Fehler:
    Debug.Print Err.Description
    MsgBox (Err.Description)
    Debug.Assert False
    Resume Next
End Sub
alle Nachrichten anzeigenGesamtübersicht  |  Zum Thema  |  Suchen

 ThemaViews  AutorDatum
Exchange Anbindung mit VB919MartinAmmerschu...13.05.05 10:08

Sie sind nicht angemeldet!
Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.

Einloggen  |  Neu registrieren

Funktionen:  Zum Thema  |  GesamtübersichtSuchen 

nach obenzurück
 
   

Copyright ©2000-2025 vb@rchiv Dieter Otter
Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.

Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel