从Windows服务访问MS Outlook [英] Access MS Outlook from Windows service

查看:72
本文介绍了从Windows服务访问MS Outlook的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过这种方式从服务访问MS Outlook:

I try to access MS Outlook from service this way:

oApp = new Outlook.Application();
oNS = (Outlook._NameSpace)oApp.GetNamespace("MAPI");
oNS.Logon(Missing.Value, Missing.Value, false, true);
oFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

如果将此代码作为Windows应用程序运行,则它可以正常工作.但是,如果我尝试以服务身份运行,则会报错

If run this code as Windows Application it is working properly. But if I try run in as service I get error

服务器不可用

在线

oNS.Logon(Missing.Value, Missing.Value, false, true);

从服务访问MS Outlook文件夹的正确方法是什么?

What is the right way to access MS Outlook folder from service?

推荐答案

Outlook与其他任何Office应用程序一样,不能从服务中使用.您的选择是

Outlook, just like any other Office app, cannot be used from a service. Your options are

  1. 如果是Exchange邮箱,则可以使用 EWS 连接到特定邮箱

扩展的MAPI (仅C ++或Delphi)-您可以动态创建配置文件,然后添加并配置Exchange MAPI服务(MSEMS).

Extended MAPI (C++ or Delphi only) - you can dynamically create a profile, then add and configure the Exchange MAPI service (MSEMS).

兑换(任何语言)-其 RDOSession .LogonExchangeMailbox/LogonHostedExchangeMailbox/LogonPstStore可以使Redemption创建动态配置文件并记录日志做到这一点.您还可以使用RDOSession.Logon并指定配置文件名称,但是服务必须以具有该配置文件的本地用户(而不是服务帐户)的身份运行.

Redemption (any language) - its RDO family of objects can be used in a service. You can use RDOSession.LogonExchangeMailbox / LogonHostedExchangeMailbox / LogonPstStore to make Redemption create a dynamic profile and log to it. You can also use RDOSession.Logon and specify the profile name, but then your service must run as the local user who has that profile instead of the service account.

这篇关于从Windows服务访问MS Outlook的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆