Profile and password usage issue in office 2003

We are developing an application which would read mail items from a common folder, let us say, TestEmailFolder (
I was given access and this folder (eg. TestEmailFolder) is configured to my profile also.

So programmatically I was able to read mail items from

But I want a generic profile with respect to  so that a windows service should be able to read mail items.
For that purpose I created another profile (say clientProfile) in outlook which points to Also I know the password.
I am trying to read mail items programmatically using following code

outlookNS.Logon(_strProfile, _strPwd, false, false);
inboxFolder = outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);

_strProfile would be clientProfile password would be that of

But still I get mail items from my inbox not from

Could you kindly advise how could I get mail items using a generic profile not using that of my profile?

Outlook.ApplicationClass oOutlkApp;
        Redemption.SafeMailItem oSafeMailItem;
        Outlook.NameSpace outlookNS;
        Outlook.MAPIFolder inboxFolder;
        oOutlkApp = new Outlook.ApplicationClass();
        outlookNS = oOutlkApp.GetNamespace("mapi");
            oSafeMailItem = new Redemption.SafeMailItem();
            String _strProfile;
            String _strPwd;
            _strProfile ="clientProfile";
            _strPwd = "*******";
            outlookNS.Logon(_strProfile, _strPwd, false, false);
            // Get items in my inbox.
            inboxFolder = outlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
            int mailItemCount;
            mailItemCount = 0;
            Response.Write("<table border=1>");
            foreach (object obj in inboxFolder.Items)
                Outlook.MailItem item = obj as Outlook.MailItem;
                if (item != null)
                    if (mailItemCount > 5)
                    oSafeMailItem.Item = item;
                    Response.Write("<td>Received: " + item.ReceivedTime.ToString() + "</td>");
                    Response.Write("<td> Sender: " + oSafeMailItem.SenderName + "</td>");
                    Response.Write("<td> Subject: " + item.Subject + "</td>");

Open in new window

Who is Participating?
Stacy SpearConnect With a Mentor President/Principal ConsultantCommented:
Is this C#? I see you logging in, but not connecting to the right profile. Also, you are creating all your variables before the logon, therefore wouldn't they point to the profile that was available to it then, which is the default profile.
David LeeCommented:
Hi, mn10191b.

I need to make sure that I understand.  On the computer where this code is running you've created an Outlook profile for the testClientCare mailbox.  In your code you are logging in to that profile, yet the messages returned are from your mailbox, not this mailbox.  Is that correct?
mn10191bAuthor Commented:
Yes your understanding is correct. So I want that generic way of accessing testClientCare mail box rather than using my profile. Because that's how it should when we deploy the application.
So could you suggest solution for this scenario
David LeeCommented:
What you're doing is the correct approach.  I'm trying to figure out how the other profile can be reading your mailbox.  What happens if you open that profile manually in Outlook?  Who's mailbox do you see?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.