Solved

exchange web services 2007 - How do I query a mailbox which is not the default for user  ?

Posted on 2008-10-10
2
681 Views
Last Modified: 2013-11-19
I am using the code snippet to access Exchange Web Services (EWS) and get a bunch of messages from Inbox, which are then moved to the Deleted Items Folder, in some other piece of code.
This is a C# Windows Service that has included the EWS definitions as a web reference.

All is working flawlessly, excepto for the fact that while using this same user, do the same kind of stuff to other mailboxes to which he also access, but are not his default one.

The Ideal would be the existance of a property that would just need to receive the mailbox name or email address:) But I am beginning to believe that cannot be done.

Thank you
exchangeServer = new xx.xxx.mpost.ExchangeServiceBinding();
exchangeServer.Url = "https://mpost.xxx.xx/ews/exchange.asmx";
System.Net.ICredentials creds = new System.Net.NetworkCredential(mailboxuser, mailboxpwd, "");
exchangeServer.Credentials = creds;
 
xx.xxx.mpost.FindItemType fit = new xx.xxx.mpost.FindItemType();
fit.Traversal = xx.xxx.mpost.ItemQueryTraversalType.Shallow;
xx.xxx.mpost.DistinguishedFolderIdType[] folderIDs = new xx.xxx.mpost.DistinguishedFolderIdType[1];
folderIDs[0] = new xx.xxx.mpost.DistinguishedFolderIdType();
folderIDs[0].Id = xx.xxx.mpost.DistinguishedFolderIdNameType.inbox;
fit.ParentFolderIds = folderIDs;
xx.xxx.mpost.ItemResponseShapeType irst = new xx.xxx.mpost.ItemResponseShapeType();
irst.BaseShape = xx.xxx.mpost.DefaultShapeNamesType.AllProperties;
fit.ItemShape = irst;
xx.xxx.mpost.FindItemResponseType firt = exchangeServer.FindItem(fit);

Open in new window

0
Comment
Question by:Apagador
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Assisted Solution

by:aa230002
aa230002 earned 20 total points
ID: 22710420
I am not very familiar with this code but would like to share a simple rule to access someone else mailbox using Outlook Web Access, which may help.

1. In case you want to access your own mailbox using Outlook web access, you will use
https://<exchange_server>/exchange
and then login your own credentials and it will open the mailbox of the user whose credentials are used.

2. In case you want to access someone else's mailbox, you will use
https://<exchange_server>/Exchange/<other_user>@domain.com
and then login using your own credentials (as you have access on other_user's mailbox.

Hope it helps.
-Amit
0
 

Accepted Solution

by:
Apagador earned 0 total points
ID: 22756299
Sorry for taking so long to answer.

Actually, I am not trying to use OWA, but actually EWS from within my own application, so the advice will not function.

On the bright side, I managed to do it myself, so I'm posting the answer here, the code that must be imbued withing the code I alredy posted.

Thanks, anyway..
pt.eap.mpost.EmailAddressType eat = new pt.eap.mpost.EmailAddressType();
eat.EmailAddress = "testemail@domain.com";
folderIDs[0].Mailbox = eat;

Open in new window

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Intune and ActiveSync 2 21
Exchange Calendars 8 58
Exchange server take over 4 53
Bulk export PST files in MS Exchange 2016 2 75
Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
In-place Upgrading Dirsync to Azure AD Connect
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question