Outlook与ASP.NET的集成 [英] Outlook integration with ASP.NET

查看:69
本文介绍了Outlook与ASP.NET的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用ASP.NET 3.5.我想从MS Outlook阅读电子邮件.我发现此链接非常有用.

http://www.c-sharpcorner.com/uploadfile/rambab/outlookintegration10282006032802am/outlookintegration.aspx [ ^ ]

我有两个问题.

1. Outlook的安全访问权限会弹出一个窗口,要求进行访问.我需要配置什么?绕过此窗口的位置.该应用程序将自动从服务器作为Web服务运行,因此此窗口看起来不会很好.

2.我找到的代码使我可以访问PC上的默认Outlook帐户.我要写什么代码才能访问另一个电子邮件帐户.换句话说,如何将用户帐户凭据传递给我要引用的Outlook DLL.

非常感谢!

Iam using ASP.NET 3.5. I want to read emails from MS outlook. I found this link which is very useful.

http://www.c-sharpcorner.com/uploadfile/rambab/outlookintegration10282006032802am/outlookintegration.aspx[^]

I have two issues.

1. Outlook''s security access pops up a window asking for access. What do I need to configure & where to by-pass this window. The application will run as a web service automatically from a server and therefore this window wont look good.

2. The code I found allows me to access the default outlook account on my pc. What code do I write to access another email account. In other words, how do I pass the user account credentials to the outlook DLL that I am referring to.

Many thanks!

推荐答案

Outlook Interop dll has a recipient class where the email address of the user can be added.  Below is the code
<br>

<code>  Outlook.Application outlook = new Outlook.ApplicationClass();
        Outlook.NameSpace ns = outlook.GetNamespace("Mapi");
        object _missing = Type.Missing;
        ns.Logon(_missing, _missing, false, false);
        
        Outlook.Recipient recipient = (Outlook.Recipient)   
        ns.CreateRecipient("email address");
        recipient.Resolve();
         
        Outlook.MAPIFolder inbox = ns.GetSharedDefaultFolder
        (recipient,Outlook.OlDefaultFolders.olFolderInbox);
        
        int unread = inbox.UnReadItemCount;
        foreach (Outlook.MailItem mail in inbox.Items)
        {
            string s = mail.Subject;
            string body = mail.Body;
        }        </code>

The code straight away accesses the emails. I think the domain user account, where the code runs, has to be an administrator account.
<br>
The permissions still keep coming. Iam currenly looking at the anti-virus programme to see anything can be configured here.</br></br>


我从下面的网站下载了一个dll,以解决Outlook的安全访问问题.
http://www.mapilab.com/download/ [
I downloaded a dll from below website to overcome Outlook''s security access issue.
http://www.mapilab.com/download/[^]
(under Advanced Security for Outlook)

I did not have to add the DLL to the ASP.NET project. I re-started my pc after the download.

The first time the application accessed outlook, I received a popup asking me to set security permission for the application accessing outlook. Once I set this up wth the correct option, Outlook''s popup message never appeared.

No side issues so far.


这篇关于Outlook与ASP.NET的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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