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

Free Support Forum - aspose.com

EWSClient.FetchItem throws "System.ArgumentException The property data could not be null"

SampleApplication.zip (137.7 KB)
Hi,

we recently updated Aspose.Mail for .NET from version 18.8 to version 22.1 and noticed, that the “FetchItem” method of the EWSClient class seems to throw errors when fetching mails that contain attachments.

I attached a standalone console application with our use case to the ticket. The zip also contains two mails: one containing attachments and one without attachments.

The mail without attachments can be processed without errors, the mail with attachments causes the “FetchItem” method to fail.

Please refer to the following code sample (or the attached sample application) to see how we use Aspose.Mail to fetch items from EWS:

// Init client
using (IEWSClient client = EWSClient.GetEWSClient(mailboxUri, username, password, domain))
{
    // Load all messages from a subfolder within the current mailbox
    string subfolder = "";
    ExchangeFolderInfo info = client.GetFolderInfo(subfolder);
    ExchangeMessageInfoCollection messagesListSubfolder = client.ListMessages(info.Uri);

    // Iterate messages from the subfolder
    foreach (ExchangeMessageInfo mail in messagesListSubfolder)
    {
        try
        {
            // Throws error "System.ArgumentException The property data could not be null. Parametername: value" when email contains attachments
            using (Aspose.Email.Mapi.MapiMessage msg = client.FetchItem(mail.UniqueUri))
            {
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
        }                    
    }
}

Please let me know if you need more information on this topic.

Best Regards,

Michael

@invoo

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as EMAILNET-40543. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@tahir.manzoor

A new version of Aspose.Email has been released on Feb 28, unfortunately our issue has not been fixed in this version.

Can we expect the fix to be part of the next release (March release)?

Best Regards,

Michael

@invoo

Currently, your issue is pending for analysis and is in the queue. Once we complete the analysis of your issue, we will then be able to provide you an estimate.

A post was split to a new topic: EWSClient.FetchItem throws "System.ArgumentException

@invoo

The System.ArgumentException issue has been fixed in the latest version of Aspose.Email for .NET 22.3.

It should be noted the FetchItem method doesn’t fetch attachments.

We added the FetchItems(EwsFetchItems options) method to EwsClient. It accepts an instance of EwsFetchItems class as a parameter to control the behavior of the method.

The following code shows how to get items with attachments.

var messageInfoList = ewsClient.ListMessages(ewsClient.MailboxInfo.InboxUri);
var options = EwsFetchItems.Create();
var uriList = messageInfoList.Select(item => item.UniqueUri).ToList();
var items = ewsClient.FetchItems(options.AddUris(uriList).WithAttachments());