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

Free Support Forum - aspose.com

Java FolderInfo.add() forgets all sender fields (aspose-email-20.5-jdk16.jar)

MapiMessage’s sender fields are not written to the .pst file.Evaluating a newly created MapiMessage, the sender fields (name, smtp address, email address) appear to have been set properly. But investigating the created .pst file, the fields are empty. This Java class demonstrates the problem:

 public class MapiMessageSenderBug
 {
    public static void main(String[] args)
    {
      File file = new File("bug-demo.pst");

      if (file.exists())
      {
          file.delete();
      }

      PersonalStorage pst = PersonalStorage.create(file.getAbsolutePath(),
          FileFormatVersion.Unicode);
      FolderInfo topFolder =
          pst.createPredefinedFolder("BugDemo", StandardIpmFolder.Inbox);
      MapiMessage mapiMessage =
          new MapiMessage("sender@a.com", "to@a.com", 
                          "demo of sender items bug", "[small body]");

      mapiMessage.setSenderEmailAddress("sender@a.com");
      mapiMessage.setSenderSmtpAddress("sender@a.com");
      mapiMessage.setSenderName("Sen Der");
      topFolder.addMessage(mapiMessage);
      pst.dispose();
      System.out.println("Wrote " + file.getAbsolutePath());
  }

}

I can also publish a dump program that dumps essential message fields from a .pst file, confirming that the sender fields are not set by Aspose Email. Exported Outlook files do provide the sender fields

aspose-bug-demo-in-outlook.png (40.5 KB)
The attachment shows the imported .pst entry in Outlook.

@gazonk.del,
Thank you for the issue description. I reproduced the problem and received the same result. I have logged the issue in our tracking system with ID EMAILJAVA-34836 for further investigation. You will be notified when it is fixed.

Thanks a lot for supporting!

@gazonk.del,
By default, the message is still being composed. It is saved but has not been sent
mapiMessage.getFlags() = MSGFLAG_UNSENT


In this mode, Outlook does not display sender information. If you need to display Sender information you should set MSGFLAG_READ flag as below:
...
mapiMessage.setSenderEmailAddress("sender@a.com");
mapiMessage.setSenderSmtpAddress("sender@a.com");
mapiMessage.setSenderName("Sen Der");

mapiMessage.setMessageFlags(MapiMessageFlags.MSGFLAG_READ);

Yes, works like a charm. Thanks for this help and tip!