reffec.com

Performing some basic steps in .NET Produce Code 3/9 in .NET Performing some basic steps

Performing some basic steps use visual .net barcode 3/9 implementation torender code 39 extended in .net iOS To work with the c Visual Studio .NET 39 barcode ode samples in this chapter, follow these steps to download the EWS Managed API: 1. Download the EWS Managed API from the following URL:.

http://www.microsoft.com/downloads/en/details. aspx FamilyID=c3342fb3-fbcc-4127-becf-872c746840e1 2. For x64 (64-bit Visual Studio .NET barcode code39 ) computers, download and run EwsManagedApi.

msi. For x86 (32-bit) computers, download and run EwsManagedApi32.msi.

3. During the installation, select a destination folder such as C:\EWS or choose the default directory C:\Program Files\Microsoft\Exchange\Web Services\1.1.

You will need to note the location so you can import the Microsoft.Exchange.WebServices.

dll assembly into the shell. You can use either a standard PowerShell console or the Exchange Management Shell to run the code for each recipe in this chapter..

13 . Getting connected to EWS When working with EWS, you first need to create an instance of the ExchangeService class that can be used to send SOAP messages to an Exchange server. This class has several properties and methods that can be used to specify explicit credentials, set the web service"s end-point URL, or make a connection using the built-in AutoDiscover client. In this recipe, you"ll learn how to make a connection to EWS that can be used to run custom scripts against the web service.

. How to do it... 1. The first thing we need to do is load the EWS Managed API assembly into the shell:. Add-Type -Path C:\EWS\Microsoft.Exchange.WebServices.dll 2. Now we can crea te an instance of the ExchangeService class:. $svc = New-Object Microsoft.Exchange.WebServices.Data. ExchangeService 3. At this point, we can use the AutoDiscoverUrl method to determine the EWS end-point on the closest Client Access Server for the mailbox with a particular SMTP address:. $svc.AutoDiscoverU barcode code39 for .NET rl("administrator@contoso.

com"). Now that we have a n Exchange service connection created, we can send e-mail messages, create and modify items within a mailbox, and perform other tasks.. How it works... Before we can star t working with the classes in the EWS Managed API, the assembly must be loaded so that the .NET Framework types are available when running scripts that utilize the API. This is only valid for the current shell session, and, if you will be creating scripts, you"ll want to make sure that this is always the first thing that is done before invoking any code.

We used the Add-Type cmdlet in the previous example to load the assembly, but this is also valid:. [System.Reflection visual .net Code 39 .

Assembly]::LoadFile( "C:\ews\Microsoft.Exchange.WebServices.

dll" ). This is basically the longhand method of doing the same thing we did before: loading an unreferenced assembly into the shell environment. Notice that in both examples, we are using the path C:\EWS. This is not the default path where the assembly is installed, but you can copy it to any folder of your choice.

. Scripting with the VS .NET USS Code 39 Exchange Web Services Managed API When creating an instance of the ExchangeService class, we have the option of versioning the connection. For example:.

$svc=New-Object Mi crosoft.Exchange.WebServices.

Data.ExchangeService ` -ArgumentList "Exchange2010_SP1". Here we are passin ANSI/AIM Code 39 for .NET g the Exchange version to the ExchangeService class constructor. When you do not provide a value, the most recent version of Exchange will be used, which in this case would be Exchange 2010 SP1, since were using the 1.

1 version of the API. The values for that can be used for Exchange are Exchange2007_SP1, Exchange2010, and Exchange2010_SP1. Since we didn"t specify credentials when creating the ExchangeService object, we need to provide the SMTP address associated with the mailbox of the currently logged on user when calling the AutoDiscoverUrl method.

. There"s more... If you want to use Visual Studio .NET barcode 3/9 explicit credentials when creating your ExchangeService object rather than using the credentials of the currently logged on user, you need to do a couple of things differently. The following code will create an instance of the ExchangeService class using an alternate set of credentials:.

$svc = New-Object Microsoft.Exchange.WebServices.

Data.ExchangeService $svc.Credentials = New-Object ` Microsoft.

Exchange.WebServices.Data.

WebCredentials ` -ArgumentList "administrator","P@ssw0rd01","contoso.com". In addition, you a barcode 3/9 for .NET lso have the option of setting the EWS URL manually:. $url = "https://ex 1.contoso.com/EWS/Exchange.

asmx" $svc.Url = New-Object System.Uri -ArgumentList $url.

Although it is pos barcode 3 of 9 for .NET sible to set the URL manually, developers use AutoDiscover as a best practice because it allows the API to determine the best Client Access Server that should be used as the web service"s end-point. A hard-coded URL value could potentially mean a broken script if things change later on in your environment.

.
Copyright © reffec.com . All rights reserved.