Blog - Title

November, 2010

Brijs Blogging... Looking Beyond the Obvious

  • Brijs Blogging... Looking Beyond the Obvious

    How to send email and create appointment item using EWS Managed API in VB.net?

    • 0 Comments

    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:

    • Send Email
    • Create Appointment

    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)
     
        End Sub
     
        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
            Try
                '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")
            Catch ex As Exception
                MessageBox.Show(ex.Message)
            End Try
        End Sub
    End Class

    We can refer to the articles mentioned below for further reading:

    Enjoy EWS and Happy Holidays!!!

  • Brijs Blogging... Looking Beyond the Obvious

    Download All New Exchange 2010 SP1 Software Development Kits

    • 0 Comments

    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.

    • Microsoft Exchange Server 2010 SP1 Web Services SDK October 2010

      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

    • Microsoft Exchange Server 2010 SP1 Backup and Restore SDK October 2010

      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

    • Microsoft Exchange Server 2010 SP1 Transport Agents SDK October 2010

      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

Page 1 of 1 (2 items)