从 C# 程序读取 Outlook 消息时如何避免 Outlook 安全警报

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/235231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-03 19:16:32  来源:igfitidea点击:

How to avoid Outlook security alert when reading outlook message from C# program

c#outlook

提问by Naga

I have a requirement of reading subject, sender address and message body of new message in my Outlook inbox from a C# program. But I am getting security alert 'A Program is trying to access e-mail addresses you have stored in Outlook. Do you want to allow this'.

我需要从 C# 程序中读取 Outlook 收件箱中新邮件的主题、发件人地址和邮件正文。但是我收到安全警报“程序正在尝试访问您存储在 Outlook 中的电子邮件地址。你想允许这个'。

By some googling I found few third party COM libraries to avoid this. But I am looking for a solution which don't require any third party COM library.

通过一些谷歌搜索,我发现很少有第三方 COM 库可以避免这种情况。但我正在寻找一种不需要任何第三方 COM 库的解决方案。

采纳答案by Kasper

Sorry, I have had that annoying issue in both Outlook 2003 and Outlook 2007 add-ins, and the only solution that worked was to purchase a Redemptionlicense. In Outlook 2007 that pesky popup should only show up if your firewall is down or your anti-virus software is outdated as far as I recall.

抱歉,我在 Outlook 2003 和 Outlook 2007 加载项中都遇到了这个烦人的问题,唯一有效的解决方案是购买赎回许可证。在 Outlook 2007 中,只有在防火墙关闭或防病毒软件过时时才会出现讨厌的弹出窗口。

回答by Aaron Fischer

If your application is not a Outlook plug in you can look at MAPIto read data from the inbox

如果您的应用程序不是 Outlook 插件,您可以查看MAPI以从收件箱中读取数据

回答by Aaron Fischer

Try this

尝试这个

Tools-->Macro-->Security-->Programmatic Access

工具-->宏-->安全-->程序化访问

Then choose Never warn me about suspicious activity.

然后选择从不警告我可疑活动。

回答by Hector Sosa Jr

"But I am looking for a solution which don't require any third party COM library."

“但我正在寻找一种不需要任何第三方 COM 库的解决方案。”

You won't find it. Kasper already pointed out the only solution that I know of. Redemption has been the only thing that has kept the Outlook plug-ins and code to work. I have done commercial Outlook add-ins for Franklin Covey. We explored a lot things, but Redemption was the only thing that got us over this hurdle.

你不会找到的。Kasper 已经指出了我所知道的唯一解决方案。赎回是唯一让 Outlook 插件和代码保持工作的东西。我已经为富兰克林柯维完成了商业 Outlook 加载项。我们探索了很多东西,但救赎是唯一让我们克服这一障碍的东西。

回答by Hector Sosa Jr

I ran into same issue while accessing sender email address for outlook mail item. To avoid 'security alert' do not create new Application object, instead use Globals.ThisAddIn.Applicationto create new mailitem.

我在访问 Outlook 邮件项目的发件人电子邮件地址时遇到了同样的问题。为了避免“安全警报”,不要创建新的 Application 对象,而是使用Globals.ThisAddIn.Application来创建新的邮件项。

string GetSenderEmail(Outlook.MailItem item)
    {
        string emailAddress = "";
        if (item.SenderEmailType == "EX")
        {
            Outlook.MailItem tempItem = (Outlook.MailItem)Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);
            tempItem.To = item.SenderEmailAddress;
            emailAddress = tempItem.Recipients[1].AddressEntry.GetExchangeUser().PrimarySmtpAddress.Trim();

        }
        else
        {
            emailAddress = item.SenderEmailAddress.Trim();

        }

        return emailAddress;
    }

回答by Jorrit Reedijk

We use Advanced Security for Outlookfrom Mapilab for this. It is free, also for commercial use, and still keeps Outlook safe (by only allowing access from approved applications). Just apposed to previously mentioned solutions that cost either money, or may compromise security.

为此,我们使用Mapilab 的Advanced Security for Outlook。它是免费的,也可用于商业用途,并且仍然保持 Outlook 安全(仅允许从批准的应用程序访问)。仅适用于前面提到的要么花钱要么可能会损害安全性的解决方案。

回答by Sandeep Aparajit

You can disable the security pop-up using Outlook's Trust Center. Check here.

您可以使用 Outlook 的信任中心禁用安全弹出窗口。检查这里