Part # 1 : Exchange Web Services (EWS) & VB.Net – Creating Calendar (non-Recurrence type)
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.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
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
Comments
Anonymous
June 16, 2009
PingBack from http://topalternativedating.info/story.php?id=10903Anonymous
January 17, 2014
good but still not clearly showed how to use it onlineAnonymous
August 12, 2014
Do you have similar code to display the attendees for a specific meeting with VB.net (2013)?