Windows服务读取Outlook邮件 [英] windows service to read outlook mail

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

问题描述

您好,

我的小窗口测试应用程序从我的Outlook中读取电子邮件正常工作。

代码仅在我的Outlook打开时才有效,否则会出现登录错误。



现在我想把它放到一个Windows服务中,以便它可以安排...

所以使用相同的代码,我已经创建了一个Windows服务来阅读我的展望...

我已将它部署到服务器上,它给出的错误如下。

我已经调查过了错误是它尝试登录Outlook的点。

有什么建议吗?

谢谢



Hello,
My little windows test application which reads email from my outlook works correctly.
The code only works if my outlook is open otherwise it gives a logon error.

Now I am trying to place it into a windows service so that it can be scheduled...
So using the same code, I have created a windows service to read my outlook...
I have deployed it onto server and the error it gives is as follows.
I have investigated and the error is on the point where it tries to logon to outlook.
Any suggestions please?
Thanks

System.Runtime.InteropServices.COMException (0x80040111): The server is not available. Contact your administrator if this condition persists. at Microsoft.Office.Interop.Outlook.NameSpaceClass.Logon(Object Profile, Object Password, Object ShowDialog, Object NewSession) ...

推荐答案

这个主题有很多手册。例如,您可以阅读CodeProject文章的这个3部分循环:

使用Exchange Server 2007(EWS)进行编程 - 第1部分 [ ^ ](交换架构和基础知识在这里解释),

使用Exchange Server 2007(EWS)编程 - 第2部分 [< a href =http://www.codeproject.com/Articles/30974/Programming-With-Exchange-Server-2007-EWS-Part-2target =_ blanktitle =New Window> ^ ](访问文件夹中的项目并搜索它们在这里解释),

使用Exchange Server 2007(EWS)编程 - 第3部分 [ ^ ](阅读这里解释了邮件。



祝你好运,

-SA
There are many manuals on this topic. For example, you can read this 3-part cycle of CodeProject articles:
Programming With Exchange Server 2007 (EWS) - Part 1[^] (Exchange architecture and the basics are explained here),
Programming With Exchange Server 2007 (EWS) - Part 2[^] (accessing items in a folder and searching them is explained here),
Programming with Exchange Server 2007 (EWS) - Part 3[^] (reading mail is explained here).

Good luck,
—SA


问题是你正在使用Outlook Interop。来自非交互式应用程序(例如Windows服务)的Office应用程序不支持Interop。



除非您更改了服务,否则该服务将作为本地系统运行,将无法访问您的Outlook。



这不应该被写为Windows服务。对于计划应用程序,您可以将其编写为普通控制台应用程序并设置计划以使用Windows计划程序运行它。您也可以将其设置为以系统运行而不是系统运行。
The problem is you're using Outlook Interop. Interop is NOT supported for Office applications from a non-interactive application, such as a Windows Service.

The service, unless you changed it, runs as Local System, which will not have any access to your Outlook at all.

This should not have been written as a Windows Service. For a "scheduled" application, you could have written this as a normal console application and setup the schedule to run it using Windows Scheduler. You can also set it up to run as you instead of as the system.


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

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