Save data to exchange

@kashif.iqbal

Can we export data to exchange like we did in pst?

Like there are two exchange servers and i want to export data of one exchange server to another. Basically i want a method by which mailboxes folder and its data is exported to exchange server and also in office 365.

@StellarDeveloper,

Thank you for writing to Aspose support team.

I am afraid that no direct method is available to export data from one exchange server to another one. However you may backup data from one exchange server to PST and then restore this PST to second exchange server using restore option. Please give it a try and share the feedback.

@kashif.iqbal

Is there any limitation on restoring pst file to exchange server because when i restore my pst file some mails are imported to my exchange.

@StellarDeveloper,

Please share your sample PST file with us for further investigation at our end.

@kashif.iqbal

Only 50 mails per folder are restoring in exchange server. Is there any restriction or this is a trial version?
Also an error occurred “Operation failed. Response code: ErrorMessageSizeExceeded, Message text: The message exceeds the maximum supported size., Cannot save changes made to an item to store.” What this error means. Is it because of message size or any other problem.

And how i abort restore process?

@StellarDeveloper,

Regarding the limitation on number of messages being restored in exchange server, it is trial version limitation as mentioned here. It states as follows:

Only 50 emails can be extracted from a folder in PST file.

This is why only 50 messages are being restored. The specific exception which you mentioned, could not be re-produced using our sample PST files here. Could you please share the sample PST file with us which can be used to re-produce the exception “The message exceeds the maximum supported size”? It will help us to observe the problem here and provide assistance accordingly.

If you want to test every aspect of the product without any limitation, please get a free 30 days license. Using this license you shall be able to test all the features without any restriction.

@kashif.iqbal

I already downloaded your api from this link, but there is older version of Aspose.Email api at this link in which there is a lot of exception or problem . So i downloaded latest version of api from your site in which there is a restriction of trial version.

Can you send me latest version of Aspose.Email without restriction.

@StellarDeveloper,

The trial version limitations are due to un-availability of valid license. You can get a 30-day temporary license free of cost and then load the latest version whcih you can get from here. There is no library version which is without restrictions. If you use library without license, restrictions are applied on the same dll. Once you have valid license, same dll starts working without restriction.

@kashif.iqbal

Can you tell me, how much time did it take to restore 30-50 GB .pst file.

@StellarDeveloper,

We haven’t experimented with this much large size PST as it may take large amount of time. In addition, creation of such a large size PST is also a time taking task that can span over days. Recommended PST file size for processing with Aspose.Email API is 5 GB for quick access of reading and writing. But there are not statistics available for restoring such large size of of PST files to Exchange server.

@kashif.iqbal

can you tell me, if there is any method to abort the backup or restore process?

@StellarDeveloper,

There is no such option at present. A feature request with id: EMAILNET-38969 has been logged for possible implementation of this. We’ll update you here once there is some information available in this regard.

@kashif.iqbal

Is there any method by which we can restore .msg file on Exchange Server like we do in .pst file.

@StellarDeveloper,

Yes, you can do so by using the IEWSClient.AppendMessage method. Please give it a try and let us know if you need any further information.

client.AppendMessage("Inbox", MapiMessage.FromFile("somemessagefile.msg"), true);

@kashif.iqbal,

client.AppendMessage is giving error if the .msg file is calendar.

How can i append items other than mail(Calendar, Contact, Journal, Todo, Notes etc.) on exchange server if i have .msg file?

Error Message : “Appending message failed. Response Code: ErrorInvalidExtendedProperty, MessageText: The extended property attribute combination is invalid.”

@StellarDeveloper,

You may please give a try to the following sample code and share the feedback.

IEWSClient client = EWSClient.GetEWSClient("https://exchange.domain.com/ews/Exchange.asmx", "user", "password", "");
try
{
    MapiMessage appointment = MapiMessage.FromFile(@"Appointment.msg");
    var emlFile = appointment.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Calendar",emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}
try
{
    MapiMessage contact = MapiMessage.FromFile(@"Contact.msg");
    var emlFile = contact.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Contacts",emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}
try
{
    MapiMessage JournalEntry = MapiMessage.FromFile(@"JournalEntry.msg");
    var emlFile = JournalEntry.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Journal",emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}
try
{
    MapiMessage mailMessage = MapiMessage.FromFile(@"MailMessage.msg");
    var emlFile = mailMessage.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Inbox",emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}
try
{
    MapiMessage meeting = MapiMessage.FromFile(@"Meeting.msg");
    var emlFile = meeting.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Calendar", emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}
try
{
    MapiMessage task = MapiMessage.FromFile(@"Task.msg");
    var emlFile = task.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Tasks", emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}
try
{
    MapiMessage taskRequest = MapiMessage.FromFile(@"TaskRequest.msg");
    var emlFile = taskRequest.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Tasks", emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}
try
{
    MapiMessage note = MapiMessage.FromFile(@"TestNote.msg");
    var emlFile = note.ToMailMessage(new MailConversionOptions() { ConvertAsTnef = true });
    client.AppendMessage("Notes", emlFile);

}
catch (Exception ex)
{

    Console.Write(ex.Message);
}

@kashif.iqbal

How would i know that sample.msg file is a calendar, contact, journal or any other format ?

Is there any method by which i know the type of a .msg file?

@StellarDeveloper,

You can use the loaded message’s MessageClass property to know about the type of message for this purpose.

@kashif.iqbal

Error occur on msg file when i use client.AppendMessage:

ExchangeException: Appending message failed. Response Code: ErrorInvalidExtendedPropertyValue, MessageText: The extended property value is inconsistent with its type.

Here i attached my code with file in which this exception occurs
foreach (FileInfo file in Files)
{
MapiMessage mapiMsg = MapiMessage.FromFile(file.FullName);
string msgClass = mapiMsg.MessageClass;
if (msgClass.CompareTo(“IPM.Note”) == 0)
client.AppendMessage(“Inbox”, MapiMessage.FromFile(file.FullName), true);
}
test file.zip (10.4 KB)

@StellarDeveloper,

Thank you for providing sample file. This issue is observed and logged under Id:EMAILNET-38991 for detailed analysis later. You will be automatically notified once any update is ready to share in this regard.