简体   繁体   中英

C# EWS Managed API : How to get mailbox maximum size or quota limit

I want to get maximum size of mailbox or quota limit. Actually I am find free space of mailbox. So I am finding used space and max space and then finding difference to find free space.

I got below code to find used size for folder. I think I can iterate to all folder to get full size. But how can I get maximum quota limit?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Exchange.WebServices.Data;
namespace ConsoleApplication12
{
    class Program
    {
        static void Main(string[] args)
        {
            ExchangeService service = new ExchangeService();
            service.Credentials = new WebCredentials("mail", "pass");
            service.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 };
            Folder Inbox = Folder.Bind(service, WellKnownFolderName.Inbox, psPropertySet);
            long FolderSize = 0;
            if (Inbox.TryGetProperty(PR_Extended_Message_Size, out FolderSize))
            {
                Console.WriteLine(FolderSize/1024);
            }
            Console.ReadKey();
        }
    }
}

您可以使用已有的代码,而不是PR_Extended_Message_Size查询PR_Prohibit_Receive_Quota (十六进制值0x666A0003),根据文档 ,这是“禁止接收邮件的限制(也是邮箱的最大大小)”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM