Click here to Skip to main content
13,258,269 members (39,921 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Iam using ASP.NET 3.5. I want to read emails from MS outlook. I found this link which is very useful.[^]

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!
Posted 30-Nov-10 12:45pm
Updated 2-Dec-10 13:18pm
Dalek Dave433.3K
Dalek Dave 2-Dec-10 18:19pm
Minor Edit for Grammar.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Outlook Interop dll has a recipient class where the email address of the user can be added.  Below is the code
<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");
        Outlook.MAPIFolder inbox = ns.GetSharedDefaultFolder
        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.
The permissions still keep coming. Iam currenly looking at the anti-virus programme to see anything can be configured here.</br></br>
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

I downloaded a dll from below website to overcome Outlook's security access issue.[^]
(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.
sujanir 5-Dec-10 16:03pm
This link has good info on codign with outlook Interop DLL. Grab it before Microsoft changes the link.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 13 Mar 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100