Create Message with Attachment

We are trying to export mail into a PST. I am able to create the PST, add folders, and messages. but the attachments are not show up when viewed in Outlook. The size of the messages lets me know the attachment is there, but it is not visible. What am I doing wrong?


import com.aspose.email.*;
import java.io.File;

public class Example
{
public static void test()
{
String pstFileName = “C:\TestRun\test.pst”;

try
{
File f = new File(pstFileName);
if (f.exists()) { f.delete();}

PersonalStorage pst = PersonalStorage.create(pstFileName, 0);

FolderInfo root = pst.getRootFolder();

FolderInfo inbox = root.addSubFolder(“Inbox”);

AddMessage(inbox, “Subject 2”, “body”, “C:\TestRun\File1.txt”);
}
catch (Exception ex)
{
System.out.println(“Exception: " + ex.getMessage());
}
}

private static void AddMessage(FolderInfo folder, String subject, String Body, String attachment)
{
MailMessage m = new MailMessage("from@domain.com”, "to@domain.com", subject, Body);

if (null != attachment)
{
Attachment att = new Attachment(attachment);
m.addAttachment(att);
}

MapiMessage message = MapiMessage.fromMailMessage(m,);
message.setMessageFlags(MapiMessageFlags.MSGFLAG_READ);

folder.addMessage(message);
}
}

Hi Craig,


Thank you for writing to us.

The issue seems to occur due to setting the message flags on the MapiMessage. I’ve logged this issue in our issue tracking system as NETWRKJAVA-33261 for further investigation by the development team. This thread has been linked with the logged issue and you’ll be notified once there is some fix available in this regard.

The issues you have found earlier (filed as NETWRKJAVA-33261) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.