We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Issues while working with Office 365

Dear Team,


We are also facing below issue. Can you please help us to solve.

1. How to move emails from Inbox to Other folder - For Office 365
2. How to fetch emails based on subject (Complete Subject text)

Hi,


Thank you for writing to us again.

Please give a try to the following sample code which moves emails with specific subject to some other folder from the Inbox.

IEWSClient client = GetAsposeEWSClient();<o:p></o:p>

//Create ExchangeMailboxInfo instance to save default mailbox info

ExchangeMailboxInfo mailbox = client.GetMailboxInfo();

//Declare variable for getting specified custom folder uri

ExchangeFolderInfo DestfolderInfo = new ExchangeFolderInfo();

//Check if specified custom folder exisits

client.FolderExists(mailbox.InboxUri, "DestinationFolder", out DestfolderInfo);

ExchangeQueryBuilder builder = new ExchangeQueryBuilder();

MailQuery qry = builder.Subject.Equals("Subject to be searched", true);

ExchangeMessageInfoCollection coll = client.ListMessages("Inbox", qry);

if (DestfolderInfo != null)

{

foreach (ExchangeMessageInfo info in coll)

{

client.MoveItem(info.UniqueUri, DestfolderInfo.Uri);

}

}

Hi,


Thank you for reply.

Above code works if destination folder is inside the Inbox. But we need to move emails outside INBOX folder.(INBOX and Destination folders are present under same root folder)

Also We can fetch 1000 Emails at a time. Can you please let us know how to fetch all the emails in inbox.

Hi,

Assuming there is a folder with name “T1” at the same level as inbox, the following code sample works fine at our end.

Sample Code:

IEWSClient client = GetOffice365Account("UserOne@Aspose2016Mar.onmicrosoft.com"); //some test office 365 account

ExchangeMessageInfoCollection msgsColl = client.ListMessages(client.MailboxInfo.InboxUri);

ExchangeFolderInfoCollection subfolders = client.ListSubFolders(client.MailboxInfo.RootUri);

foreach (ExchangeFolderInfo fi in subfolders)
{
if (fi.DisplayName.Equals(“T1”))
client.MoveItem(msgsColl[0].UniqueUri, fi.Uri);
}

For your other issue of emials fetched at a time limited to 1000, the issue is already known to us and logged as EMAILNET-35159 in our issue tracking system. We’ll update you here once there is some information available in this regard.

Dear Team,


Kindly please revert on this, as it is pending since long time.

Also we are randomly getting below error while fetching emails from the office 365 mail server. Can you please let us know cause of the issue,

Error: at .(String , & , Int64& )
at .GetMailboxInfo()
at .get_MailboxInfo()
Dear Team,

Please revert on the issue as early as possible, waiting for response since long time.

We are also getting below error randmly while fetching emails from office 365 mail server. Please let us know cause of the issue.
Error: at .(String , & , Int64& )
at .GetMailboxInfo()
at .get_MailboxInfo()

Hi,

Our Product team has investigated this issue and have found it to be configuration settings with Office 365 server that returns result by pages, ignoring client settings. In order to work correctly, please use the paging support with 1000 items per page as detailed in this example.