示例:使用 Dynamics 365 for Outlook 方法
发布日期: 2017年1月
适用于: Dynamics 365 (online),Dynamics 365 (on-premises),Dynamics CRM 2016,Dynamics CRM Online
此示例代码适用于 Microsoft Dynamics 365(在线或本地)。下载 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 365 for Outlook
为 Microsoft Dynamics 365 for Outlook 编写自定义代码
Microsoft Dynamics 365
© 2017 Microsoft。 保留所有权利。 版权