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

Free Support Forum - aspose.com

Adding attachment to the the MapiTask

Hi,

I’m trying to add the attachment to the MapiTask, using this code , but it seems that attachment is not added:

MapiTask task = new MapiTask("subject", date1, date2);

final MapiAttachmentCollection attahCollection = retTask.getAttachments();

attahCollection.add("file.jpg", byte[]);


Please advise.

Thanks.

Hi,

Thank you for writing to Aspose support team.

Please try the following code sample at your end for adding attachments to MapiTask and let us know your feedback.

Sample Code:

MapiTask task = new MapiTask("To Do", "Just click and type to add new tasks", new Date(), new Date());
Path p = FileSystems.getDefault().getPath("", "DContactp.jpg");
try
{
task.getAttachments().add("TestAtt.jpg", Files.readAllBytes(p));
}
catch (IOException e)
{
e.printStackTrace();
}
task.save("MapiTask.msg", TaskSaveFormat.Msg);

Hi,

Can you please explain what is the difference with my code? I see only that you read tge bytes and I have byte array loaded before


Thanks

Hi,

I’ve tested your example and also saved my MapiTask to the disk as msg files.
All looks good with attachments, but when I add those MapiTasks to the PST then I don’t see any attachment.

Please check.

Hi,

I am afraid that I could not re-produce the scenario here as following code is used for the testing and the newly added task in PST contains the attachment. Could you please give it a try and let us know the feedback?

MapiTask task = new MapiTask(“To Do”, “Just click and type to add new tasks”, new Date(), new Date());
Path p = FileSystems.getDefault().getPath("", “D:/Aspose/images (1).jpg”);
try
{
task.getAttachments().add(“TestAtt.jpg”, Files.readAllBytes§);
}
catch (IOException e)
{
e.printStackTrace();
}
//task.save(“MapiTask.msg”, TaskSaveFormat.Msg);
PersonalStorage pst = PersonalStorage.create(“D:/Aspose/Tasks.pst”, FileFormatVersion.Unicode);
FolderInfo tmpFolder = pst.createPredefinedFolder(“Tasks”, StandardIpmFolder.Tasks);
tmpFolder.addMapiMessageItem(task);

Hi,

I tried your code (with my image attachment) and I don’t see any attachment in the created task.
Please see attached PST.

Thanks

Hi,

With the latest version of Aspose.Email for Java 4.7.0, I have tested this issue at my end with the aforementioned sample code and an image as attachment. The attachment is visible in the Task body. Please find the attachment image and output PST as attached to this post. Could you please make sure that you are using the latest version of Aspose.Email at your end? If the issue still persists, please provide us with your sample attachment file that you are trying to attach to the PST task. We’ll look into it for assisting you further.

Hi,

I’m using version 4.7.0.
The issue is happening with any image or file.
Did you managed to open the pst I sent you? Do you see image in the task body?

Thanks

Hi,

Yes, I have managed to open the PST you sent earlier and the attachment is available in there. You can see the screenshot here where the Task is open and the attachment image is also opened. Please let us know if we can be of any additional help to you in this regard.

Hi,

Seems it’s mac problem, the outlook for Mac doesn’t shows attachments in the task item.

Sorry and Thanks for your support.

Hi,

Thanks for sharing the feedback and feel free to write to us in case you have any additional query/inquiry related to Aspose.Email.