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

Free Support Forum - aspose.com

PST Issue adding a message to a folder

I am taking a message from WebDAV in mime format and attempting to add it to the PST. I am Getting (Invalid operation exception -- This is not a structured storage file.) I can write it to dasd and view it ok in Mozilla Thunderbird. I can export to Exchange 2010 with no issues. Am using the following command;

inboxFolder.AddMessage(MapiMessage.FromFile(@"c:\aaatemp\Msg0.EML"));

Msg0.msg does not work either.

If I create the message from my email files on my desktop outlook machine it does work. Do I have to referrence something other than outlook? I am creating the PST using

Aspose.Email.Outlook.Pst.PersonalStorage pst = Aspose.Email.Outlook.Pst.PersonalStorage.Create(PTS_File_Name, FileFormatVersion.Unicode);

How do I write a mime message from WebDAV to the PST?

Hi Tom,


Thank you for considering Aspose.

To demonstrate the concept of adding messages to newly created PST file, I have used the EWS (not WebDav) to extract messages from Exchange Server and added these extracted messages to the “Inbox” folder of the PST. Same will be applicable with WebDav. Please find the sample source as below and try it at your end with WebDav.

C#

// Call ListMessages method to list messages info from Inbox
var msgCollection = client.ListMessages(client.MailboxInfo.InboxUri);
// Create a new PST file
using(var pst = PersonalStorage.Create(“sample.pst”, FileFormatVersion.Unicode))
{
// Add a folder to the Root of PST
pst.RootFolder.AddSubFolder(“Inbox”);
// Get the newly created folder
var pstFolder = pst.RootFolder.GetSubFolder(“Inbox”);
// loop through the collection to get Message URI
foreach (var msgInfo in msgCollection)
{
string strMessageURI = msgInfo.UniqueUri;
// Save the message in an instance MailMessage
var message = client.FetchMessage(strMessageURI);
// Add the message to Inbox folder of PST
pstFolder.AddMessage(MapiMessage.FromMailMessage(message));
}
}