Restore PST to Exchange Mailbox

Hi!

In my program I need some functionality: I have PST file with some folders and emails and I need to restore this content to some mailbox on Exchange Server.

I think first I need to open PST:

PersonalStorage pst = PersonalStorage.FromFile(pstFileName);

What is after that?

Hi Sergey,

Thank you for contacting Aspose Support team.

IEWSClient class provides feature to restore PST messages to exchange server. Following sample code demonstrates this feature where all the folders and respective messages are copied from PST to the mail box on Exchange server.

const string mailboxUri = “https:[//exchange.domain.com/ews/Exchange.asmx](https://exchange.domain.com/ews/Exchange.asmx)”;
const string domain = @"";
const string username = @“userName”;
const string password = @“password”;
NetworkCredential credentials = new NetworkCredential(username, password, domain);
IEWSClient client = EWSClient.GetEWSClient(mailboxUri, credentials);
string inputPst = @“Source.pst”;
client.Restore(inputPst, RestoreOptions.RemoveNonexistentItems);

Could you please give a try to the sample code and let us know your feedback?

Hello sir,
I want to restore the PST file to the exchange server according to the folders which i want to upload to the server not the whole pst, along with the emails/task/contacts needed to be uploaded.
I want a relevant code for doing this.
Thanks & regards
Mantu Malakar

@mantumalakar1,

Aspose.Email provides rich features to restore contents from PST file. Along with the pst file to the Restore funstion, you may provide the ExchangeFolderInfoCollection and RestoreOptions. The folders which are mentioned in the collection will be restored from the PST only along with the restore options mentioned in RestoreOptions argument. This is the simplest way of uploading the data from PST to exchange server.

void Restore(string fileName, RestoreOptions options);
void Restore(Stream stream, RestoreOptions options);
void Restore(PersonalStorage pst, RestoreOptions options);
void Restore(string fileName, ExchangeFolderInfoCollection folders, RestoreOptions options);
void Restore(Stream stream, ExchangeFolderInfoCollection folders, RestoreOptions options);
void Restore(PersonalStorage pst, ExchangeFolderInfoCollection folders, RestoreOptions options);

However if you want to select particular mails, tasks and contacts etc. then you may please use functions which individually upload contents like AppendMessage(), CreateAppointment, CreateContact, CreateNote and CreateTask. For this read item from PST file and use respective fucntion according to the type of item. I am afraid that no such simple function is available which can be used to upload such type of filters which you have mentioned.

For parsing the PST folder and subfolders please, have a look at the following link:
Read Outlook PST File and Get Folders and SubFolders Information

You may please look into following code samples for working on different types of items:

Distribution List
Working with Folders on Exchange Server
Working with Tasks
Working with Contacts
Working with Calendar Items
Working with Exchange Mailbox and Messages