How to Save EML File to Office 365 and Exchange Server?

Platform C#
how to convert eml to office 365 and pst to office 365 (single eml/pst and multiple eml/pst)
and
how to convert eml to exchange server and pst to exchange server (single eml/pst and multiple eml/pst)

@mukundmalpaniweb,
Thank you for posting the query.

You can use EWSClient class instance to upload EML messages to Office 365 and Exchange servers as shown below:

ewsClient.AppendMessage("FolderName", emailMessage);

IEWSClient interface contains AppendMessages method for uploading message collections.

To read messages from a PST file, use the next code snippet:

using (var personalStorage = PersonalStorage.FromFile("input.pst", false))
{
    var folderInfos = personalStorage.RootFolder.EnumerateFolders();
    foreach (var folderInfo in folderInfos)
    {
        var messageInfos = folderInfo.EnumerateMessages();
        foreach (var messageInfo in messageInfos)
        {
            var mapiMessage = personalStorage.ExtractMessage(messageInfo);
            // ...
        }
    }
}

More examples:
Working with Exchange Mailbox and Messages
Working with Messages in a PST File

API Reference:
EWSClient Class
PersonalStorage Class
MailMessage Class
MapiMessage Class

Please provide detail solution for this issue…please provide details from initialize to implementation

@mukundmalpaniweb,
I am sorry for my hasty answer. Please use the following code snippet for adding messages to specified folders:

var mailboxUri = "https://outlook.office365.com/ews/exchange.asmx";
var userName = "username";
var password = "password";

using (var ewsClient = EWSClient.GetEWSClient(mailboxUri, userName, password))
{
    var mailMessage = MailMessage.Load("example.eml");

    var subfolderInfo = new ExchangeFolderInfo();
    // Note: FolderName folder exists in my root folder
    if (ewsClient.FolderExists(ewsClient.MailboxInfo.RootUri, "FolderName", out subfolderInfo))
    {
        ewsClient.AppendMessage(subfolderInfo.Uri, mailMessage);
    }
}

Documents: Working with Folders on Exchange Server
API Reference: ExchangeFolderInfo

How to create folder and subfolder (on office 365 and Exchange server) and save email/save msg into this ?

@mukundmalpaniweb,
The next code example demonstrates how to do it:

using (var ewsClient = EWSClient.GetEWSClient(mailboxUri, userName, password))
{
    var folderInfo = ewsClient.CreateFolder(ewsClient.MailboxInfo.RootUri, "Folder");
    var subfolderInfo = ewsClient.CreateFolder(folderInfo.Uri, "Subfolder");

    using (var mapiMessage = MapiMessage.FromFile(dataPath + "message.msg"))
    {
        ewsClient.AppendMessage(subfolderInfo.Uri, mapiMessage, true);
    }
}