在 Outlook 中显示新电子邮件
- Windows 应用程序调用业务逻辑
- 业务逻辑使用 Exchange Web Services 创建新电子邮件,并将电子邮件的条目 ID 返回给 Windows 应用程序
- Windows 应用程序尝试通过 Outlook 查找并显示新电子邮件基于电子邮件的条目 ID 的互操作。
使用缓存 Exchange 模式时,上述方法不起作用。 Outlook 仅检查邮件的本地缓存,并且由于该邮件刚刚在服务器上创建,因此不会立即在本地可用。
但是,当帐户未使用缓存 Exchange 模式时,它可以正常工作,因为 Outlook 会检查 Exchange Server 中的电子邮件。
那么,问题是:
如何确保 Outlook 在查找邮件之前检查 Exchange Server 而不是本地缓存,或者至少与服务器同步?
下面是我们用来根据条目 ID 显示电子邮件的(简化的)代码:
void ShowEmail(string entryId)
{
// (COM release and error handling removed for readability)
var app = new Microsoft.Office.Interop.Outlook.Application();
var ses = app.Session;
var mailItem =
(Microsoft.Office.Interop.Outlook.MailItem)ses.GetItemFromID(entryId);
mailItem.Object.Display(true);
}
- Windows application invokes business logic
- Business logic creates new e-mail using Exchange Web Services and returns Entry ID of e-mail to Windows application
- Windows application attempts to find and display new e-mail via Outlook Interop based on the Entry ID of the e-mail.
The above doesn't work when using Cached Exchange Mode. Outlook only checks the local cache for the message, and since it was just created on the server, it won't be immediately available locally.
However, it works just fine when the account isn't using Cached Exchange Mode, because Outlook checks the Exchange Server for the e-mail.
So, the question:
How do I ensure that Outlook checks the Exchange Server instead of the local cache, or at least syncs with the server before looking for the message?
Here's the (simplified) code we use to display e-mails based on their Entry IDs:
void ShowEmail(string entryId)
{
// (COM release and error handling removed for readability)
var app = new Microsoft.Office.Interop.Outlook.Application();
var ses = app.Session;
var mailItem =
(Microsoft.Office.Interop.Outlook.MailItem)ses.GetItemFromID(entryId);
mailItem.Object.Display(true);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法控制邮箱的上传或同步。请参阅这篇文章。如果用户使用缓存 Exchange 模式 - 他们无法使用此功能。
如果您有权访问注册表 - 您可以尝试禁用缓存 Exchange 模式,然后重新启用它。请参阅这篇文章,其中修改注册表以启用/禁用 CEM 。
You have no control over the upload or sync of the mailbox. See this post. If the user is using Cached Exchange Mode - they can't use this feature.
If you have access to the registry - you could try disabling Cached Exchange Mode, and then re-enabling it. See this post which modifies the registry to enable/disable CEM.