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

Free Support Forum - aspose.com

Handling multiple attachment

Hi,
If I have multiple attachment how can i add into pst file.Please reply soon.

Hi Pooja,


You can not add attachments directly to the PST. You first need to add these to MailMessage or MapiMessage and then add that message to the PST. Please have a look at our article for further clarification and the following code for your kind reference.

Sample Code:

PersonalStorage pst = PersonalStorage.Create(“Attachments.pst”, FileFormatVersion.Unicode);<o:p></o:p>

FolderInfo folderInfo = pst.RootFolder.AddSubFolder("Test");

MailMessage mailMsg = new MailMessage();

mailMsg.Attachments.Add(new Attachment("someAttachment.txt"));

MapiMessage mapiMsg = MapiMessage.FromMailMessage(mailMsg);

folderInfo.AddMessage(mapiMsg);