It does seem to be a bit of a dearth of VB.net samples for Exchange Web Service Managed API. So here is a sample VB.net code which demonstrates:
NOTE: Following programming examples is for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This sample code assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. This sample code is provided for the purpose of illustration only and is not intended to be used in a production environment.
Imports System.Net
Imports System.Net.Security
Imports Microsoft.Exchange.WebServices.Data
Imports System.Security.Cryptography.X509Certificates
Public Class Form1
'Creating Servie object for EWS service binding endpoint
Dim service As New ExchangeService(requestedServerVersion:=ExchangeVersion.Exchange2007_SP1)
Private Sub cmdSendMail_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSendMail.Click
Try
'Create new message object and set properties required to send a mail
Dim message As EmailMessage = New EmailMessage(service)
message.Subject = "Hello from the EWS Managed API"
message.Body = "Now that's easy!"
message.ToRecipients.Add("testex2007@bex2007.com")
message.SendAndSaveCopy()
MessageBox.Show("Email Sent!!!")
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Add a valid EWS service end point here or user Autodiscover
service.Url = New Uri("https://server/ews/exchange.asmx")
'Add a valid user credentials
service.Credentials = New WebCredentials("User", "Password", "Domain")
'To address the SSL challenge
ServicePointManager.ServerCertificateValidationCallback = New RemoteCertificateValidationCallback(AddressOf ValidateCertificate)
Private Function ValidateCertificate(ByVal sender As Object, ByVal certificate As X509Certificate, ByVal
chain As X509Chain, ByVal sslPolicyErrors As SslPolicyErrors) As Boolean
'Return True to force the certificate to be accepted.
Return True
End Function
Private Sub cmdCreateAppointment_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles cmdCreateAppointment.Click
'Create appointment object and set properties as required
Dim appt As Appointment = New Appointment(service)
appt.Subject = "Holidays"
appt.Body = "The appointment is for holiday placeholder"
appt.Start = New DateTime(2010, 11, 1)
appt.End = appt.Start.AddHours(24)
appt.IsAllDayEvent = True
appt.LegacyFreeBusyStatus = LegacyFreeBusyStatus.OOF
appt.Save(WellKnownFolderName.Calendar, SendInvitationsMode.SendToNone)
MessageBox.Show("Appointment Added to Calendar")
End Class
We can refer to the articles mentioned below for further reading:
Enjoy EWS and Happy Holidays!!!
If you are developing the applications for Exchange Server, then you can download all new Exchange Server 2010 SP1 SDKs from the Download Center now.
This release of the Exchange 2010 Service Pack 1 (SP1) Web Services Software Development Kit (SDK) provides new and updated documentation and samples for building applications that use Web services in Exchange 2010 SP1 . Use this SDK to help you develop collaborative Web services-based enterprise applications. Download
This release of the Exchange Server 2010 Service Pack 1 (SP1) Backup and Restore SDK provides information about how to create applications that back up, restore, and recover Exchange 2010 databases. Download
This release of the Exchange 2010 Service Pack 1 (SP1) Transport Agents Software Development Kit (SDK) provides new and updated documentation and samples for building applications that use Microsoft Exchange transport agents. Use this SDK to help you develop collaborative enterprise applications for Exchange transport. Download