Zugriff auf Exchangeserver (SBS 2008) via Webservices

  • VB.NET

    Zugriff auf Exchangeserver (SBS 2008) via Webservices

    Hallo Leute,
    ich hab das Problem das ich mit VB6 eine Exchangeschnittstelle programmiert habe die allerdings unter 64Bit nicht funktioniert.
    Nun wollte ich das in VB2008 nacholen und gleich via Webservices Programmieren.

    VB.NET-Quellcode

    1. Imports System
    2. Imports System.Collections.Generic
    3. Imports System.Collections
    4. Imports System.Text
    5. Imports System.Net
    6. Imports System.Xml
    7. Imports System.Net.Security
    8. Imports System.Security
    9. Imports System.Web
    10. Imports System.IO
    11. Imports Microsoft.Win32
    12. Imports System.Reflection
    13. 'Imports System.DirectoryServices
    14. Imports System.Web.Services
    15. Imports System.Security.Cryptography.X509Certificates
    16. Imports EWSUtil.EWS
    17. Public Class Form1
    18. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    19. Dim esb = New ExchangeServiceBinding()
    20. esb.Credentials = New NetworkCredential("user", "pass", "domain")
    21. esb.Url = "https://domain/EWS/exchange.asmx"
    22. ' Create the appointment.
    23. Dim appointment As New CalendarItemType()
    24. ' Add item properties to the appointment.
    25. appointment.Body = New BodyType()
    26. appointment.Body.BodyType1 = BodyTypeType.Text
    27. appointment.Body.Value = "Agenda Items...."
    28. appointment.Categories = New String() {"Category1", "Category2"}
    29. appointment.Importance = ImportanceChoicesType.High
    30. appointment.ImportanceSpecified = True
    31. appointment.ItemClass = "IPM.Appointment"
    32. appointment.Subject = "Advance Design Presentation"
    33. ' Add calendar properties to the appointment.
    34. appointment.Start = System.DateTime.Parse("2009-11-06T14:00:00Z")
    35. appointment.StartSpecified = True
    36. appointment.[End] = System.DateTime.Parse("2009-11-06T15:00:00Z")
    37. appointment.EndSpecified = True
    38. ' Identify the destination folder that will contain the appointment.
    39. Dim folder As New DistinguishedFolderIdType()
    40. folder.Id = DistinguishedFolderIdNameType.calendar
    41. ' Create the array of items that will contain the appointment.
    42. Dim arrayOfItems As New NonEmptyArrayOfAllItemsType()
    43. arrayOfItems.Items = New ItemType(0) {}
    44. ' Add the appointment to the array of items.
    45. arrayOfItems.Items(0) = appointment
    46. ' Create the CreateItem request.
    47. Dim createItemRequest As New CreateItemType()
    48. ' The SendMeetingInvitations attribute is required for calendar items.
    49. createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToNone
    50. createItemRequest.SendMeetingInvitationsSpecified = True
    51. ' Add the destination folder to the CreateItem request.
    52. createItemRequest.SavedItemFolderId = New TargetFolderIdType()
    53. createItemRequest.SavedItemFolderId.Item = folder
    54. ' Add the items to the CreateItem request.
    55. createItemRequest.Items = arrayOfItems
    56. Try
    57. ' Send the request and get the response.
    58. Dim createItemResponse As CreateItemResponseType = esb.CreateItem(createItemRequest)
    59. ' Get the response messages.
    60. Dim rmta As ResponseMessageType() = createItemResponse.ResponseMessages.Items
    61. For Each rmt As ResponseMessageType In rmta
    62. Dim itemArray As ArrayOfRealItemsType = DirectCast(rmt, ItemInfoResponseMessageType).Items
    63. Dim items As ItemType() = itemArray.Items
    64. ' Get the item identifier and change key for each item.
    65. For Each item As ItemType In items
    66. Console.WriteLine("Item identifier: " & item.ItemId.Id)
    67. Console.WriteLine("Item change key: " & item.ItemId.ChangeKey)
    68. Next
    69. Next
    70. Catch e As Exception
    71. Console.WriteLine("Error Message: " & e.Message)
    72. End Try
    73. End Sub
    74. End Class


    Den Code kann ich durchlaufen sofern ich das Try rausnehme, aber er legt mir kein Termin an bzw ich seh ihn nicht im OWA.

    Mit dem Try macht er mir das hier

    "Die Variable "e" verbirgt eine Variable in einem einschließenden Block."
    Ich kenne mich nocht nicht soo gut mit 08 aus was bedeutet das denn?

    "domain", "pass", "user" steht hier nur für Platzhalter

    Hoffe jemand kann mir helfen ggf noch ein paar Tipps geben was die Sache mit Exchange angeht.

    Danke schonmal!