tags:

views:

3565

answers:

7

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'.

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.

+5  A: 

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 Redemption license. 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.

Kasper
The unfortunate truth is that there were so many abuses of Outlook that Microsoft has it locked down and doesn't provide a way around it. I guess you could attempt replicate what Redemption does yourself, but I doubt the cost/benefit could beat the $200 license.
Godeke
indeed, $200 is nothing compared to the time you would need to come up with something like redemption
Kasper
+1  A: 

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

Aaron Fischer
+2  A: 

Try this

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

Then choose Never warn me about suspicious activity.

I go for the kiss principle. I searched stackoverflow found this thread shall we call it. Read all about the fancy solutions. Read this one. Tried it and Dang what do you know. It worked. Thats the kind of simple solution I like. I was lucky that my client was using Outlook2007. Not all earlier Outlooks have this option.
All these options are disabled in my Outlook 2007. Is it because we have an Exchange Server? Is it possible to set it via group policies or something like that?
Lars
I don't see Programmatic Access in 2003
Jeff
+2  A: 

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

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.

hectorsosajr
Actually, I have been able to automatically "click" away this message so that the user doesn't notice it (2003 and 2007). In a commercial app.
danbystrom
@Danbystrom: How did you do that?
Jeff
@Jeff: Fooling Outlook to believe that the OK button is being pressed by a human...
danbystrom
@danbystrom: Did you use something like SendKeys ~ ? Since the dialog in Outlook hangs my application, I can't see that working. I'm interested in what you did
Jeff
@Jeff: I don't want to give away too much: there's a reason the dialog is there. I just wanted to point out that the answer "You won't find it" is dead wrong. Don't stop looking. :-) Here are some clues: as for Outlook hanging you app, you need to start a background thread to do the work for you before starting to talk to Outlook. As for SendKeys - no, Outlook is smarter than that and will figure out what's going on. But there are other, common, well documented API functions that can be combined to do the trick.
danbystrom
+1  A: 

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.Application to create new mailitem.

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;
    }
If you are creating an actual outlook add-in (and not an external application that is tapping into Outlook), then this is the correct answer. In process addins do not trigger the warning dialog box as long as they only use the Application object that they were given by Outlook at startup (i.e. don't create a new Application object).
Erv Walter
+1  A: 

We use Advanced Security for Outlook from 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.

Jorrit Reedijk
A: 

You can disable the security pop-up using Outlook's Trust Center. Check this: http://msdn.microsoft.com/en-us/library/bb226709.aspx

Thanks! Sandeep Aparajit

Sandeep Aparajit