473,409 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

Visual Studio2005 C# Mailbox Size

Hi there, i am trying to get the size of a user's mailbox Outlook 2003, using visual studio2005 , C#...

The problem is i get an error when running the foll code...
NOTE: servername = name of server authenticating against...
Expand|Select|Wrap|Line Numbers
  1.  public string GetMailboxSize()
  2.         {
  3.  
  4.             try
  5.             {
  6.                 System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher();
  7.                 searcher.Scope = new System.Management.ManagementScope("\\\\servername\\root\\MicrosoftExchangeV2");
  8.                 searcher.Query = new System.Management.ObjectQuery("Select * From Exchange_Mailbox");
  9.                 System.Management.ManagementObjectCollection results = searcher.Get();
  10.                 foreach (System.Management.ManagementObject mailbox in results)
  11.                 {
  12.                     mailboxsize = Convert.ToUInt64(mailbox.Properties["Size"].Value);
  13.  
  14.                     //storagegroupname = mailbox.Properties["StorageGroupName"].Value.ToString();
  15.                     //storename = mailbox.Properties["StoreName"].Value.ToString();
  16.                     //mailboxdisplayname = mailbox.Properties["MailboxDisplayName"].Value.ToString();
  17.  
  18.                 }
  19.  
  20.                 return (Convert.ToString(mailboxsize));
  21.             }
  22.             catch (Exception x)
  23.             {
  24.                 throw (x);
  25.  
  26.             }
  27.         }
  28.  
ERROR:
The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)


Can anybody help me with regards to this problem...? Ihave turned off the firewall on my local machine....
Thanks...!!
Aug 21 '08 #1
3 2887
Plater
7,872 Expert 4TB
When connecting to a remote computer, you need to supply credentials.
Something like:
Expand|Select|Wrap|Line Numbers
  1. ConnectionOptions connection = new ConnectionOptions();
  2. connection.Username = userNameBox.Text;
  3. connection.Password = passwordBox.Text;
  4. connection.Authority = "ntlmdomain:mydomain";
  5.  
  6. ManagementScope scope = new ManagementScope(
  7.                     "\\\\servername\\root\\MicrosoftExchangeV2", connection);
  8. scope.Connect();
  9.  
Aug 21 '08 #2
When connecting to a remote computer, you need to supply credentials.
Something like:
Expand|Select|Wrap|Line Numbers
  1. ConnectionOptions connection = new ConnectionOptions();
  2. connection.Username = userNameBox.Text;
  3. connection.Password = passwordBox.Text;
  4. connection.Authority = "ntlmdomain:mydomain";
  5.  
  6. ManagementScope scope = new ManagementScope(
  7.                     "\\\\servername\\root\\MicrosoftExchangeV2", connection);
  8. scope.Connect();
  9.  

Hi there Plater....
Thanks for that.....

I did include a username and password after i posted after doing some research....

I added the co.Authority = "ntlmdomain:mydomain"; and searcher.Scope.Connect(); lines of code.....

ConnectionOptions co = new ConnectionOptions();
co.Username = "mtcexchdev";
co.Password = "monte@qaz";
co.Authority = "ntlmdomain:mydomain"; //change added




System.Management.ManagementObjectSearcher searcher = new System.Management.ManagementObjectSearcher();
searcher.Scope = new System.Management.ManagementScope("\\\\MTCEXCH01.g aming.tsogosun.com\\root\\MicrosoftExchangeV2",co) ; //change added
searcher.Scope.Connect(); //change added
searcher.Query = new System.Management.ObjectQuery("Select * From Exchange_Mailbox");
System.Management.ManagementObjectCollection results = searcher.Get();



I however getting the following Error Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

I have turned off the firewall on my side, and linked the server in SQL 2005, and provided the correct username and password....and enabled RPC = True...

IMPORTANT: what needs to be filled in here :
connection.Authority = "ntlmdomain:mydomain";

Do you think that it could be a problem on the mailbox server side??

I am currently working at head office where the server is based at the client which is in the next building....i just cannot figure out what else could be causing this problem??

And once again...thank you for assisting me, if theres anybody that can help me its you...you knowledge is quite out there!!! :-)
Aug 22 '08 #3
Plater
7,872 Expert 4TB
well "mydomain" needs to be replaced with whatever your actual domain is.
Aug 22 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Alex Martelli | last post by:
All my mailboxes have been filling up with files of about 130k to 150k, no doubt copies of some immensely popular virus. So, I've no doubt lost lots of real mail because of "mailbox full"...
0
by: Morten | last post by:
Hi! I'm trying to create a script that can list users in an OU and retrieve their current mailbox size. I can fairly easily get the user list but how can I make a lookup and get the mailbox size...
0
by: vangawk | last post by:
Hi, I am using Visual Studio2005 on a Windows XP SP2 English environment. Recently I have come across a problem where CPU shows 100% usage whenever I try to run an application which throws up an...
1
by: jimbi2006 | last post by:
hello is there anyone who can say me how I can make a library in visual studio 2005? and how can I use it in my program?
1
by: mavi | last post by:
i am designing a website in asp.net using visual studio2005, how to use AJAX in it to enhance website appearance
3
by: =?Utf-8?B?QU0=?= | last post by:
Is there a way to work on visual studio 2003 projects using visual studio 2005 without converting, maintaining original code? Thanks AM
0
by: azmat123 | last post by:
Hi All , I want all of you participate in this discussion and post your issues related Visual Studio 2005. First of all i wana share my issue if any one has idea about this issue then kindly tell...
4
by: KDawg44 | last post by:
Hi, I am frustrated with my users who send large files around the office instead of using the network shares. For instance, this is one of many emails I have sent around: "If you take the...
10
shoonya
by: shoonya | last post by:
Hi, I am bit new to visual studio. I am having following error while building the project. LDR: LdrpWalkImportDescriptor() failed to probe abc.dll for its manifest, ntstatus 0xc0150002 ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.