Tag Cloud

CRM 2011 (161) CRM 4.0 (144) C# (116) JScript (109) Plugin (92) Registry (90) Techpedia (77) PyS60 (68) WScript (43) Plugin Message (31) Exploit (27) ShellCode (26) FAQ (22) JavaScript (21) Killer Codes (21) Hax (18) VB 6.0 (17) Commands (16) VBScript (16) Quotes (15) Turbo C++ (13) WMI (13) Security (11) 1337 (10) Tutorials (10) Asp.Net (9) Safe Boot (9) Python (8) Interview Questions (6) video (6) Ajax (5) VC++ (5) WebService (5) Workflow (5) Bat (4) Dorks (4) Sql Server (4) Aptitude (3) Picklist (3) Tweak (3) WCF (3) regex (3) Config (2) LINQ (2) PHP (2) Shell (2) Silverlight (2) TSql (2) flowchart (2) serialize (2) ASHX (1) CRM 4.0 Videos (1) Debug (1) FetchXml (1) GAC (1) General (1) Generics (1) HttpWebRequest (1) InputParameters (1) Lookup (1) Offline Plug-ins (1) OutputParameters (1) Plug-in Constructor (1) Protocol (1) RIA (1) Sharepoint (1) Walkthrough (1) Web.config (1) design patterns (1) generic (1) iframe (1) secure config (1) unsecure config (1) url (1)

Pages

Thursday, May 09, 2013

Use the Methods in the Outlook SDK Assembly

This sample shows how to use the methods and properties in the assembly Microsoft.Crm.Outlook.Sdk. Before running this sample, you should start Microsoft Dynamics CRM for Outlook.



   1:  //# [Use the Methods in the Outlook SDK Assembly ]

   2:  using System;

   3:  using CrmSdk;

   4:  using Microsoft.Crm.Sdk.Utility;

   5:  using Microsoft.Crm.Outlook.Sdk;

   6:   

   7:  namespace Microsoft.Crm.Sdk.HowTo.Outlook

   8:  {

   9:     public class CrmOutlookMethodsSample

  10:     {

  11:        public CrmOutlookMethodsSample()

  12:        {

  13:   

  14:        }

  15:        

  16:        // NOTE:  Before running this sample, you should start the Microsoft Dynamics CRM for Outlook.

  17:        

  18:        public static bool Run(string crmServerUrl, string orgName)

  19:        {

  20:           bool success = true;

  21:   

  22:           try

  23:           {

  24:              // Set up the CRM Service.  

  25:              CrmOutlookService outlookService = new CrmOutlookService();

  26:   

  27:              // Determine if the Outlook client is running.

  28:              if (outlookService.IsCrmClientLoaded)

  29:              {

  30:                 if (outlookService.IsCrmDesktopClient)

  31:                 {

  32:                    // Microsoft Dynamics CRM for Outlook cannot go offline.

  33:                    Console.WriteLine("CRM Client Desktop URL: " + outlookService.ServerUri.AbsoluteUri);

  34:                    Console.WriteLine("CRM Client state: " + outlookService.State.ToString());

  35:                 }

  36:                 else

  37:                 {

  38:                    // See if Microsoft Dynamics CRM for Outlook with Offline Access is offline.

  39:                    if (outlookService.IsCrmClientOffline)

  40:                    {

  41:                       Console.WriteLine("CRM Client Offline URL: " + outlookService.ServerUri.AbsoluteUri);

  42:                       Console.WriteLine("CRM Client state: " + outlookService.State.ToString());

  43:                       

  44:                       // Take Microsoft Dynamics CRM for Outlook online.

  45:                       Console.WriteLine("Going Online...");

  46:                       outlookService.GoOnline();

  47:                       

  48:                       // Sync up with Microsoft Dynamics CRM database.

  49:                       Console.WriteLine("Synchronizing with CRM...");

  50:                       outlookService.Sync(OutlookSyncType.Outlook);

  51:   

  52:                       Console.WriteLine("CRM Client state: " + outlookService.State.ToString());

  53:                    }

  54:                    else

  55:                    {

  56:                       Console.WriteLine("CRM Client Online URL: " + outlookService.ServerUri.AbsoluteUri);

  57:                       Console.WriteLine("CRM Client state: " + outlookService.State.ToString());

  58:                       

  59:                       // Before going offline, sync up with the Microsoft Dynamics CRM database.

  60:                       Console.WriteLine("Synchronizing with CRM...");

  61:                       outlookService.Sync(OutlookSyncType.Outlook);

  62:                       

  63:                       // Take Microsoft Dynamics CRM for Outlook offline.

  64:                       Console.WriteLine("Going Offline...");

  65:                       outlookService.GoOffline();

  66:   

  67:                       Console.WriteLine("CRM Client state: " + outlookService.State.ToString());

  68:                    }

  69:                 }

  70:              }

  71:           }

  72:           catch (System.Web.Services.Protocols.SoapException)

  73:           {

  74:              // Perform error handling here.

  75:              throw;

  76:           }

  77:           catch (Exception)

  78:           {

  79:              throw;

  80:           }

  81:           

  82:           return success;

  83:        }

  84:     }

  85:  }