How to migrate a function UploadItemFts(string folderId, byte[data]) on EWS managed api to Graph function

39 Views Asked by At

I'm migrating EWS Managed api to Graph. When I use EWS Managed API, it has the function UploadItemFts(string folderId, byte[data]). This function helps to move a message(it has all properties) from mailbox X to mailbox Y.

public string UploadItemFts(string folderId, byte[] data)
    {
        try
        {             
            UploadItem itemToUpload = new UploadItem(_service)
            {
                ParentFolderId = folderId,
                Data = data,
                CreateAction = CreateAction.CreateNew
            };

            var uploadItemResult = _service.UploadItem(itemToUpload);
            if (uploadItemResult.Result == ServiceResult.Success)
            {
                return uploadItemResult.Id.UniqueId;
            }
            else
                throw new Exception(uploadItemResult.ErrorMessage);
        }
        catch (ServiceResponseException srex)
        {
            string details = Shared.DumpServiceResponseException(srex);
            XLogger.Debug(this, string.Format("ExportMessageFTS >> ServiceResponseException >> {0}", details));
            throw new Exception(details);
        }
    }

    public UploadItemsResponse UploadItem(UploadItem item)
    {
        //XLogger.Audit(this, AuditCategory.Exchange, CommonUtils.GetLocalIPAddress(), "UploadItem({0})".FormatString(item?.Data));
        UploadItemsRequest request = new UploadItemsRequest(this, ServiceErrorHandling.ReturnErrors);

        request.Items = new UploadItem[] { item };
        
        return request.Execute()[0];
    }

I don't see any Graph API to support doing this. Could you guys have any recommendations? Thanks.

1

There are 1 best solutions below

7
Dmitry Streblechenko On

Graph does not support UploadItems operation or anything similar. You can try to work with the raw MIME source, but that will miss all MAPI-specific properties that are not mapped to MIME.