Part # 1 : Exchange Web Services (EWS) & VB.Net – Creating Calendar (non-Recurrence type)


                    Le Café Central de
Deva              

                                 
                                 ..... Deva blogs!!




 

 

Part # 1 : Exchange Web Services (EWS) & VB.Net – Creating Calendar (non-Recurrence type)

  • Comments 2

Hi Peers,

I have include the part 1 of Exchange Web Services & VB.Net. Earlier my couple of VB developer customers were looking for relevant VB.Net related articles and found very few. Keeping in that mind, i have created this EWS_VB.net_Calendar thread to start with.

In this session we will going to see how we can create the Calendar using Exchange Web Services (EWS). I tried to provide things as simpler as i can…

I would appreciate to know if you have any suggestions/clarifications regarding this…

 

Step 1: Create Exchange Service Binding

'Create Exchange Service Binding
Dim esb As New ExchangeServiceBinding()
'Provide the NetworkCredential
esb.Credentials = New NetworkCredential("username", "password", "domain")
'Provide the URL
esb.Url = https://Fully qualified domain/ews/exchange.asmx


Step 2: Create Calendar

' Create the appointment.
Dim appointment As New CalendarItemType()


Step 3: Set the properties of the appointment

' Set the properties of the appointment.
appointment.Start = "2/24/2009 12:30:00PM"
appointment.StartSpecified = True
appointment.[End] = "2/24/2009 1:30:00PM"
appointment.EndSpecified = True
appointment.Subject = "Planning meeting by Deva"
appointment.Location = "Building 3, Room 311"
appointment.Body = New BodyType()
appointment.Body.BodyType1 = BodyTypeType.Text
appointment.Body.Value = "Plan the department party."

Step 4: Add the required attendees

' Add required attendees.
appointment.RequiredAttendees = New AttendeeType(1) {}
appointment.RequiredAttendees(0) = New AttendeeType()
appointment.RequiredAttendees(0).Mailbox = New EmailAddressType()
appointment.RequiredAttendees(0).Mailbox.EmailAddress = "chris@contoso.com"

Step 5: Create the array of items that will contain the appointment

' Create the array of items that will contain the appointment.
Dim arrayOfItems As New NonEmptyArrayOfAllItemsType()
arrayOfItems.Items = New ItemType(1) {}
 
' Add the appointment to the array of items.
arrayOfItems.Items(0) = appointment
 
' Create the CreateItem request.
Dim createRequest As New CreateItemType()
 
'The SendMeetingInvitations attribute is required for calendar items.
createRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy
createRequest.SendMeetingInvitationsSpecified = True
 
'Add the destination folder(calendar) to the CreateItem request.
createRequest.SavedItemFolderId = New TargetFolderIdType()
Dim dfCalendarFolder As DistinguishedFolderIdType = New DistinguishedFolderIdType()
dfCalendarFolder.Id = DistinguishedFolderIdNameType.calendar
createRequest.SavedItemFolderId.Item = dfCalendarFolder


Step 6: Add the items to CreateItem request

' Add the items to the CreateItem request.
createRequest.Items = arrayOfItems
 

Step 7: Create the appointment by calling the CreateItem method & Check the result

' Create the appointment by calling the CreateItem method, which has the side effect of sending invitations to attendees.
Dim createResponse As CreateItemResponseType = esb.CreateItem(createRequest)
 
' Check the result.
If createResponse.ResponseMessages.Items(0).ResponseClass <> ResponseClassType.Success Then
     Throw New Exception("SendAppointment failed.")
Else
            Console.WriteLine("Calendar Item Created")
End If


Step 8: Result

image

Page 1 of 1 (2 items)
Blog - Post Feedback Form(CAPTCHA)
Leave a Comment
  • Post