Profile Picture

how to count emails of user

Posted By i-Kirby 6 Years Ago
You don't have permission to rate!
Author
Message
i-Kirby
Posted 6 Years Ago
View Quick Profile
Forum Member

Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 5, Visits: 5
Hello,



I need to get the amount of email in the mailbox of the user (trash, inbox, outbox, ...), all of them. I know how to get maximum, but current amount....



Can you help me please with code?



thank you
Mike Barber
Posted 6 Years Ago
View Quick Profile
Time Traveler

Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)

Group: Administrators
Last Active: 2 Months Ago
Posts: 480, Visits: 19.4K
using IMailAPI_NET;



namespace Utility

{

   class Program

   {

      static void Main(string[] args)

      {

         DomainCollection domains = new DomainCollection();



         foreach (DomainData domain in domains.DomainArray)

         {

            UserCollection users = new UserCollection(domain.HostName);

            foreach (UserData user in users.UserArray)

            {

               MailboxCollection mailboxes = new MailboxCollection(user.UserID, domain.HostName);

               foreach (Mailbox mailbox in mailboxes)

               {

                  Console.WriteLine ("Doamin: '{0}' User: '{1}' Mailbox: '{2}' MessageCount: {3}",

                     domain.HostName, user.UserID, mailbox.Name, mailbox.MessageCount);

               }

            }

         }

         return;

      }

   }

}

Mike Barber
Senior Software Developer
Ipswitch, Inc
i-Kirby
Posted 6 Years Ago
View Quick Profile
Forum Member

Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)Forum Member (27 reputation)

Group: Forum Members
Last Active: 6 Years Ago
Posts: 5, Visits: 5
Thank you for your answer.



I tryed your code and got the exception: 'Requested registry access is not allowed'.
Mike Barber
Posted 6 Years Ago
View Quick Profile
Time Traveler

Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)Time Traveler (666 reputation)

Group: Administrators
Last Active: 2 Months Ago
Posts: 480, Visits: 19.4K
That error is a permissions error. To resolve it try one of the following.



Assuming you are running this from inside IIS try setting the App Pool as Network Service.



Assuming you are running this from inside the debugger make sure Visual Studio is running with Administrator privileges.

Mike Barber
Senior Software Developer
Ipswitch, Inc


Similar Topics


Reading This Topic