How to find Shared Mail Box Size
private static void FindSizeofEachMailBoxes()
{
string WVMailBoxNames = ConfigurationManager.AppSettings["MailBoxIds"].ToString();
string userMailId = ConfigurationManager.AppSettings["userMailId"].ToString();
string userpassWord = ConfigurationManager.AppSettings["userPassWord"].ToString();
string userdomain = ConfigurationManager.AppSettings["userDomain"].ToString();
try
{
string[] WVMailBoxes = WVMailBoxNames.Split(new char[] { '^' });
foreach (string WVMailBox in WVMailBoxes)
{
if (!string.IsNullOrEmpty(WVMailBox))
{
string WVMailOLBox = WVMailBox.Trim().ToUpper();
try
{
ExchangeService MyService = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
MyService.Credentials = new WebCredentials(userMailId, userpassWord, userdomain);
MyService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
ExtendedPropertyDefinition PR_Extended_Message_Size = new ExtendedPropertyDefinition(3592, MapiPropertyType.Long);
PropertySet psPropertySet = new PropertySet(BasePropertySet.FirstClassProperties) { PR_Extended_Message_Size };
//Microsoft.Exchange.WebServices.Data.Folder Inbox = Microsoft.Exchange.WebServices.Data.Folder.Bind(MyService, WellKnownFolderName.Inbox, psPropertySet);
Microsoft.Exchange.WebServices.Data.Folder Inbox = Microsoft.Exchange.WebServices.Data.Folder.Bind(MyService, new FolderId(WellKnownFolderName.Inbox, WVMailOLBox), psPropertySet);
long FolderSize = 0;
if (Inbox.TryGetProperty(PR_Extended_Message_Size, out FolderSize))
{
Console.WriteLine("MailBox Name:" + WVMailOLBox + " Size KB :" + FolderSize / 1024 );
}
}
catch (System.Exception OIExp)
{
Console.WriteLine("MailBox Name:"+WVMailOLBox+" " + OIExp.Message);
}
}
}
}
catch (System.Exception OExp)
{
Console.WriteLine("ReadWorkViewNAMailSupport Exception" + OExp.Message);
}
}
{
string WVMailBoxNames = ConfigurationManager.AppSettings["MailBoxIds"].ToString();
string userMailId = ConfigurationManager.AppSettings["userMailId"].ToString();
string userpassWord = ConfigurationManager.AppSettings["userPassWord"].ToString();
string userdomain = ConfigurationManager.AppSettings["userDomain"].ToString();
try
{
string[] WVMailBoxes = WVMailBoxNames.Split(new char[] { '^' });
foreach (string WVMailBox in WVMailBoxes)
{
if (!string.IsNullOrEmpty(WVMailBox))
{
string WVMailOLBox = WVMailBox.Trim().ToUpper();
try
{
ExchangeService MyService = new ExchangeService(ExchangeVersion.Exchange2013_SP1);
MyService.Credentials = new WebCredentials(userMailId, userpassWord, userdomain);
MyService.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
ExtendedPropertyDefinition PR_Extended_Message_Size = new ExtendedPropertyDefinition(3592, MapiPropertyType.Long);
PropertySet psPropertySet = new PropertySet(BasePropertySet.FirstClassProperties) { PR_Extended_Message_Size };
//Microsoft.Exchange.WebServices.Data.Folder Inbox = Microsoft.Exchange.WebServices.Data.Folder.Bind(MyService, WellKnownFolderName.Inbox, psPropertySet);
Microsoft.Exchange.WebServices.Data.Folder Inbox = Microsoft.Exchange.WebServices.Data.Folder.Bind(MyService, new FolderId(WellKnownFolderName.Inbox, WVMailOLBox), psPropertySet);
long FolderSize = 0;
if (Inbox.TryGetProperty(PR_Extended_Message_Size, out FolderSize))
{
Console.WriteLine("MailBox Name:" + WVMailOLBox + " Size KB :" + FolderSize / 1024 );
}
}
catch (System.Exception OIExp)
{
Console.WriteLine("MailBox Name:"+WVMailOLBox+" " + OIExp.Message);
}
}
}
}
catch (System.Exception OExp)
{
Console.WriteLine("ReadWorkViewNAMailSupport Exception" + OExp.Message);
}
}
Comments