Guest User

Untitled

a guest
Jan 18th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. ConnectionOptions conn = new ConnectionOptions();
  2. conn.Impersonation = ImpersonationLevel.Impersonate;
  3. conn.Authentication = AuthenticationLevel.Default;
  4.  
  5. // Create a management scrope into the Exchange WMI namespace
  6. exmangescope =
  7. new System.Management.ManagementScope(@"\.RootMicrosoftExchangeV2");
  8.  
  9. // Create a query to get the data from the Exchange WMI //List
  10. System.Management.ObjectQuery objquery =
  11. new System.Management.ObjectQuery("Select * FROM Exchange_Queue");
  12.  
  13. // Retrieves a collection of management objects based on the query.
  14. System.Management.ManagementObjectSearcher objsearch =
  15. new System.Management.ManagementObjectSearcher(exmangescope, objquery);
  16.  
  17. System.Management.ManagementObjectCollection queryCollection1 = null;
  18.  
  19. // Invokes the WMI query and returns the resulting collection.
  20. try {
  21. queryCollection1 = objsearch.Get();
  22. } catch (System.Runtime.InteropServices.COMException comEx) {
  23. log4.Debug("ExchangeQueue 2003 receiving queues", comEx);
  24. throw comEx;
  25. }
  26.  
  27.  
  28. // Loop through each item in the collection
  29.  
  30. log4.Debug( "QueueCount:" + queryCollection1.Count );
  31. foreach (System.Management.ManagementObject instmailbox in queryCollection1) { do Stuff}
Add Comment
Please, Sign In to add comment