示例:使用 CRM for Outlook 方法
发布日期: 2016年11月
适用于: Dynamics CRM 2015
此示例代码适用于 Microsoft Dynamics CRM 2015 和 Microsoft Dynamics CRM Online 2015 更新。下载 Microsoft Dynamics CRM SDK 包。 它可能位于下载包的以下位置:
SampleCode\CS\Client\Outlook\UseOutlookSdk.cs
要求
有关运行此 SDK 中提供的示例代码的要求的详细信息,请参阅使用示例和帮助程序代码。
演示
此示例显示如何使用 Microsoft.Crm.Outlook.Sdk.dll 程序集中的可用方法。
示例
// 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());
}
}
}
另请参阅
CrmOutlookService
GoOnline
GoOffline
扩展 Microsoft Dynamics CRM 2015 for Outlook
为 Microsoft Dynamics CRM 2015 for Outlook 编写自定义代码
© 2017 Microsoft。 保留所有权利。 版权