Delen via


Voorbeeld: Dynamics 365 gebruiken voor Outlook-methoden

 

Gepubliceerd: januari 2017

Is van toepassing op: Dynamics 365 (online), Dynamics 365 (on-premises), Dynamics CRM 2016, Dynamics CRM Online

Deze voorbeeldcode is voor Microsoft Dynamics 365 (online en on-premises).Download het Microsoft Dynamics CRM SDK-pakket. U vindt deze op de volgende locatie in het download-pakket:

SampleCode\CS\Client\Outlook\UseOutlookSdk.cs

Vereisten

Voor meer informatie over de vereisten voor het uitvoeren van de voorbeeldcode in deze SDK, zie Het voorbeeld en de helpercode gebruiken.

Demonstreert

Dit voorbeeld toont hoe u de methoden gebruikt die beschikbaar zijn in de assembly Microsoft.Crm.Outlook.Sdk.dll.

Voorbeeld


// Set up the CRM Service.  
CrmOutlookService outlookService = new CrmOutlookService();

// Determine if the Outlook client is running
if (outlookService.IsCrmClientLoaded)
{
    if (outlookService.IsCrmDesktopClient)
    {
        // The desktop client cannot go offline
        Console.WriteLine("CRM Client Desktop URL: " +
            outlookService.ServerUri.AbsoluteUri);
        Console.WriteLine("CRM Client state: " +
            outlookService.State.ToString());
    }
    else
    {
        // See if laptop client is offline
        if (outlookService.IsCrmClientOffline)
        {
            Console.WriteLine("CRM Client Offline URL: " +
                outlookService.ServerUri.AbsoluteUri);
            Console.WriteLine("CRM Client state: " +
                outlookService.State.ToString());

            // Take client online
            // NOTE: GoOnline() will automatically Sync up with CRM
            // database, no need to call Sync() manually
            Console.WriteLine("Going Online...");
            outlookService.GoOnline();

            Console.WriteLine("CRM Client state: " +
                outlookService.State.ToString());
        }
        else
        {
            Console.WriteLine("CRM Client Online URL: " +
                outlookService.ServerUri.AbsoluteUri);
            Console.WriteLine("CRM Client state: " +
                outlookService.State.ToString());

            // Take client offline 
            // NOTE: GoOffline triggers a synchronization of the
            // offline database with the online server.
            // If a sync is not required, you can use SetOffline().
            Console.WriteLine("Going Offline...");
            outlookService.GoOffline();

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

Zie ook

CrmOutlookService
GoOnline
GoOffline
Microsoft Dynamics 365 voor Outlook uitbreiden
Aangepaste code schrijven voor Microsoft Dynamics 365 voor Outlook

Microsoft Dynamics 365

© 2017 Microsoft. Alle rechten voorbehouden. Auteursrecht