Hi,
i work with visual studio 2008 and VB.net
i would like to write a message (mailMessage) into a MBox file
this is the code:
'create the MBox file
writerMB = New MboxStorageWriter(“c:\test\mboxfile”, False) PROBLEM
’load a msg file
msg = MailMessage.Load(FileEntry, MessageFormat.Msg)
’ Add this message to storage
writerMB.WriteMessage(msg)
the problem is that i obtain a compilation error : New MboxStorageWriter is not possible because the class has the Musthinerit flag !!!
why ? MboxrdStorageWriter class works well.
how can i use it ?
thanks for your help
marc
Hi Marc,
Please accept our apology for delayed response.
We have analyzed the information provided by you and found that MboxStorageWriter is a base class whose object cannot be initiated however MboxrdStorageWriter is a derived class and can be used for this purpose. Please have a look at the following code which uses MboxrdStorageWriter for writing to Mbox.
Imports Aspose.Email.Formats.MboxImports Aspose.Email.MailImports System.IOImports Aspose.Email.Outlook.PstModule Module1Sub Main()writeMBox()readMBox()End SubSub writeMBox()Dim writerMB As MboxrdStorageWriter = New MboxrdStorageWriter("mboxfile", False)Dim mailMsg As MailMessage = MailMessage.Load("Mail.msg", MessageFormat.Msg)writerMB.WriteMessage(mailMsg)writerMB.Dispose()End SubSub readMBox()Dim readerMB As MboxrdStorageReader = New MboxrdStorageReader("mboxfile", False)Dim msg As MailMessage = New MailMessagemsg = readerMB.ReadNextMessage()While Not (msg Is Nothing)msg.Save("MailOut.msg", MailMessageSaveType.OutlookMessageFormat)msg = readerMB.ReadNextMessage()End WhilereaderMB.Dispose()End SubEnd Module
Please feel free to share your feedback and we will be glad to provide you assistance if required.