Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Outlook
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!
Posted 30-Nov-10 12:45pm
sujanir749
Edited 2-Dec-10 13:18pm
Dalek Dave432.9K
v2
Comments
Dalek Dave at 2-Dec-10 18:19pm
   
Minor Edit for Grammar.
Rate this: bad
good
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");
        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.
 

The permissions still keep coming. Iam currenly looking at the anti-virus programme to see anything can be configured here.</br></br>
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
v2
Comments
sujanir at 5-Dec-10 16:03pm
   
http://support.microsoft.com/kb/310244
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
0 OriginalGriff 495
1 Maciej Los 340
2 Richard MacCutchan 265
3 BillWoodruff 225
4 Mathew Soji 200
0 OriginalGriff 8,804
1 Sergey Alexandrovich Kryukov 7,457
2 DamithSL 5,689
3 Maciej Los 5,279
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web03 | 2.8.1411028.1 | Last Updated 13 Mar 2011
Copyright © CodeProject, 1999-2014
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