使用MAPI从服务访问Exchange服务器 [英] Using MAPI to access the Exchange Server from a Service

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

问题描述

我与建设,将使用MAPI检查邮件的应用程序的任务。我做了使用包装类的在CPP编码,这是从C#访问。我认识到,合并托管和非托管代码的不一定是最好的路径,但它是什么,我可以去上班。

I was tasked with building an application that would check email using MAPI. I made use of a wrapper class coded in cpp, which is accessed from c#. I realize that combining managed and unmanaged code is not necessarily the best path, but it was what I could get to work.

得到它的工作后,我被要求做该应用程序的服务,所以它可以运行时没有登录系统。

After getting it working, I was asked to make the application a service, so it could be run when the system was not logged in.

客户要求我们使用MAPI,并使用Outlook 2007,但我会喜欢它要与x86和x64架构的同时兼容。在几个工作站上运行一个单独的程序将被允许使用一个电子邮件地址发送邮件。该服务将监控该帐户,从Exchange看着新的电子邮件,说消息无法传递。发生这种情况时,它会记在数据库中以供将来修正。

The client requires us to use MAPI, and is using Outlook 2007, but I would like it to be compatible with both x86 and x64 architecture. A separate program running on several workstations will be allowed to send mail using a single email address. The service will monitor this account, watching for new email from Exchange saying a message could not be delivered. When this happens, it will make a note in the database for future correction.

我如何扩展MAPI工作的理解是,它使用的人登录的个人资料访问Exchange服务器。我的问题是,是否在Exchange Server可以通过MAPI访问时,没有人登录到系统?如果这是不可能的,并OOM允许访问一个特定的电子邮件帐户(或轮廓),当没有用户登录?将一种方法是优于其他主要使用C#时?

My understanding of how Extended MAPI works is that it uses the profile of the person logged in to access the Exchange Server. My question is whether the Exchange Server can be accessed through MAPI when nobody is logged into the system? If this is not possible, does OOM allow for access to a specific email account (or profile) when no user is logged in? Would one method be better than the other when predominantly using c#?

下面是一个简短的样本如何,我增加了第二种方法,包装类的日志,但从来没有得到它登录到比当前用户的其他配置文件。

Below is a brief sample of how the wrapper class logs in. I added the second method, but never did get it to log in to a profile other than that of the current user's.

BOOL CMAPIEx::Login(LPCTSTR szProfileName, BOOL bInitAsService)
{
    DWORD dwFlags=MAPI_EXTENDED | MAPI_USE_DEFAULT | MAPI_NEW_SESSION;
    if(bInitAsService) dwFlags|=MAPI_EXPLICIT_PROFILE | MAPI_NT_SERVICE;
    return (MAPILogonEx(NULL, (LPTSTR)szProfileName, NULL, dwFlags, &m_pSession)==S_OK);
}

BOOL CMAPIEx::Login(LPCTSTR szProfileName, LPCTSTR szProfilePassword, BOOL bInitAsService)
{
    DWORD dwFlags=MAPI_EXTENDED | MAPI_EXPLICIT_PROFILE  | MAPI_NEW_SESSION;
    if(bInitAsService) 
        dwFlags|= MAPI_NT_SERVICE;
    return (MAPILogonEx(NULL, (LPTSTR)szProfileName, (LPTSTR)szProfilePassword, dwFlags, &m_pSession)==S_OK);
}

感谢您的任何建议。

推荐答案

您可以动态创建与MSEMS服务临时配置文件并配置它。结果
见的 http://support.microsoft.com/kb/306962?wa=wsignin1.0 并滚动到使用MAPI IProfAdmin接口结果
确保服务中的邮箱所有者的身份运行。

You can dynamically create a temporary profile with the MSEMS service and configure it.
See http://support.microsoft.com/kb/306962?wa=wsignin1.0 and scroll to "Use the MAPI IProfAdmin interface"
Make sure the service runs under the identity of the mailbox owner.

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

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