Browse our Products

Aspose.Email for Java 25.11 Release Notes

All Changes

KeySummaryCategory
EMAILNET-41620Implement the ability to add attachments to messages in PSTFeature
EMAILNET-41653Issue in message extraction from PSTBug
EMAILNET-41654Error occurring during item updates in PST foldersBug
EMAILNET-41645NullReferenceException when calling ListMessages method using Graph API clientBug
EMAILNET-41649NullReferenceException occurs during MSG to EML conversion when content-type named property has a null valueBug
EMAILNET-41644Incorrect recurrence pattern when creating Monthly/Yearly Ordinal appointments via MS GraphBug
EMAILNET-41643Graph CreateCalendarItem ignores MAPI reminderBug
EMAILJAVA-35415Incorrect handling of recurring events during ICS to PST conversionBug

New Features

Ability to Add Attachments to Messages in PST

The PersonalStorage class has been enhanced with new methods that allow adding attachments directly to messages stored within a PST file. This functionality provides greater flexibility for modifying existing messages by programmatically attaching files or streams.

The following methods have been introduced:

  • addAttachmentToMessage(MessageInfo messageInfo, String name, InputStream stream) Adds an attachment to the specified message using the provided stream as the attachment content.

  • addAttachmentToMessage(MessageInfo messageInfo, String filePath) Adds an attachment to the specified message using the file located at the given path.

  • addAttachmentToMessage(String entryId, String name, InputStream stream) Adds an attachment to the message identified by the specified entry ID using the provided stream.

  • addAttachmentToMessage(String entryId, String filePath) Adds an attachment to the message identified by the specified entry ID using the file located at the given path.

Here’s a simple example demonstrating how to add an attachment to a message in a PST file using the addAttachmentToMessage method:


// Load the PST file
try (PersonalStorage pst = PersonalStorage.fromFile("Outlook.pst")) {
    // Get the Inbox folder
    FolderInfo inbox = pst.getRootFolder().getSubFolder("Inbox");

    // Retrieve information about the first message
    MessageInfo messageInfo = inbox.getContents().get_Item(0);

    // Specify the file to attach
    String attachmentPath = "C:\\Documents\\Report.pdf";

    // Add the attachment to the message
    pst.addAttachmentToMessage(messageInfo, attachmentPath);
}

This example loads an existing PST file, accesses the Inbox folder, retrieves the first message, and adds a file (Report.pdf) as an attachment to that message. The operation modifies the message directly inside the PST without the need to extract or rebuild it.