I’m trying to create a Task trough Aspose.Email and then save it as a .msg file so it can be opened with Outlook to send to people.
I have succeeded in creating the task and saving it to .msg but the Recipients don’t seem to be used.
I saved a .msg from Outlook which behaves as I want it too: task.zip (10.2 KB)
Screenshot: image.png (13.8 KB)
This is a piece of the code I used:
MapiTask task = new MapiTask();
task.Subject = “My subject”;
task.Body = “Content”;
task.Mode = MapiTaskMode.NotAssigned;
task.Users.Owner = “Darius”;
task.Recipients.Clear();
task.Recipients.Add(“test@test.be”, “name”, MapiRecipientType.MAPI_TO);
// Initial test, but doest not retain Recipients after converting to MapiMessage
//task.Save
MemoryStream ms = new MemoryStream();
task.Save(ms, TaskSaveFormat.Msg);
ms.Position = 0;
var message = Aspose.Email.Mapi.MapiMessage.FromStream(ms);
// Recipients are empty, add them again
message.Recipients.Add(“test@test.be”, “name”, MapiRecipientType.MAPI_TO);
message.Save(“MapiTask.msg”, Aspose.Email.SaveOptions.DefaultMsgUnicode);
I have observed the message file, image and sample code shared by you. Can you please explain what else you are expecting to have in To field. You have used following statement and it added that to recipient.
@mudassir.fayyaz I read the information you linked to but it does not provide me with a solution.
If you try out the code I posted you will see that you will not get the sender field when opening the .msg file in Outlook.
We do not have access to an exchange server however…
As the .msg format clearly supports sending the task as an email, I supposed Aspose would be able to create such a file, but apparently it is not possible?
@mudassir.fayyaz
Thank you for the response, I tried it out with the latest version of Aspose and indeed it works as expected.
We have an older version of Aspose however (4.9.0) so I tried porting the code to that version and came up with the following:
String path = @"C:\Email\MapiTask3.msg";
var fileName = path;
MapiTask task = new MapiTask();
task.Subject = "My subject";
task.Body = "Content";
task.Mode = MapiTaskMode.NotAssigned;
task.Users.Owner = "Darius";
task.Mode = MapiTaskMode.RequestEmbedded;
MemoryStream ms = new MemoryStream();
task.Save(ms, TaskSaveFormat.Msg);
ms.Position = 0;
var message = Aspose.Email.Outlook.MapiMessage.FromStream(ms);
message.Recipients.Add("test@test.be", "name", MapiRecipientType.MAPI_TO);
message.SetMessageFlags(MapiMessageFlags.MSGFLAG_UNSENT | MapiMessageFlags.MSGFLAG_READ);
message.Save(fileName);
This seems to be identical, but the Send button does not show when opening the saved file.
Do you know if there is anything I can do in our version to solve this issue?
I have observed your comments. Can you please try to use Aspose.Email latest version 19.5 on your end. I also like to inform that as per company policy support always provided based on new version so please try to use latest version and if there is still an issue than report here so that we may help you out.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
Enables storage, such as cookies, related to analytics.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.
Sets consent for personalized advertising.
Cookie Notice
To provide you with the best experience, we use cookies for personalization, analytics, and ads. By using our site, you agree to our cookie policy.
More info
Enables storage, such as cookies, related to analytics.
Enables storage, such as cookies, related to advertising.
Sets consent for sending user data to Google for online advertising purposes.