VB.Net, App - MAPI.Session as "foreign" User?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chrisli
    New Member
    • Nov 2008
    • 11

    VB.Net, App - MAPI.Session as "foreign" User?

    Hello,

    i'm trying to make an Application which can get every Calendar entry from a FOREIGN User in Outlook on a Exchange 2003 Server.

    At the moment i can only get my own calender entries. But i need to get the Entries from another User.

    Here's my actually code:

    Code:
    Dim osession As New MAPI.Session
    Dim vEmpty As Object = System.Reflection.Missing.Value
    
    osession.Logon(vEmpty, vEmpty, False, False, vEmpty, vEmpty, vEmpty)
    
    Dim ofolder As Object = osession.GetDefaultFolder(MAPI.CdoDefaultFolderTypes.CdoDefaultFolderCalendar)
    Dim oMessages = ofolder.Messages
    Dim oAppointment = oMessages.GetFirst
    
    Do While Not oAppointment Is Nothing
    
    MsgBox("Appointment: " & oAppointment.Subject & vbCrLf & _
    "Start Time: " & oAppointment.StartTime & vbCrLf & _
    "End Time: " & oAppointment.EndTime & vbCrLf & _
    "Location: " & oAppointment.Location & vbCrLf & _
    "Description: " & oAppointment.Text & vbCrLf)
    oAppointment = oMessages.GetNext
          
     Loop
    Is there any way to do this?

    Thank you!

    Chris

    P.s
    Sorry for my bad english.
  • chrisli
    New Member
    • Nov 2008
    • 11

    #2
    Solved it :)

    Here you go :)
    Code:
    Public Sub ReadOtherUserAppointment()
            Dim objolApp As New Outlook.Application
            Dim objNS As Outlook.NameSpace
            Dim objRecip As Outlook.Recipient
            Dim objFolder As Outlook.MAPIFolder
            Dim UserName As String = "m.mustermann" 
    
            objNS = objolApp.GetNamespace("MAPI")
            objRecip = objNS.CreateRecipient(UserName)
            objRecip.Resolve()
    
            If objRecip.Resolved Then
    
                objFolder = objNS.GetSharedDefaultFolder(objRecip, Outlook.OlDefaultFolders.olFolderCalendar)
    
                For i As Integer = 1 To objFolder.Items.Count
                    'For example...
                    MsgBox(objFolder.Items.Item(i).Subject)
                    MsgBox(objFolder.Items.Item(i).Start)
                Next
    
            End If
        End Sub
    The User has to Share his Calender with you.

    Greetings

    Comment

    Working...