Mapi Task Stop working

Hi,

If I create a Mapi Task without the Start And End date and try to send that task to a user then it stop working. but code is being executed successfully. please see the below code.

In Outlook we can create a Task without start and end date.

MapiTask task = new MapiTask();

task.Subject=“Aspose Task Test”;

task.Body=“Test Body”;

task.PercentComplete = claimTask.PercentComplete;

task.EstimatedEffort = 2000;

task.ActualEffort = 20;

task.History = MapiTaskHistory.Assigned;

task.LastUpdate = DateTime.Now;

task.Users.Owner = claimTask.Owner;

MemoryStream ms = new MemoryStream();

task.Save(ms, TaskSaveFormat.Msg);

ms.Position = 0;

// Convert to TNEF eml. Such a feature would allow to send messages by mail clients,

// where the information, specific for Outlook task, would be stored.

MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(msg.MessageClass);

MailMessage eml = mi.InterpretAsTnef(msg);

eml.From = "abc@domain.com";

eml.To.Clear();

eml.To.Add(new Aspose.Email.Mail.MailAddress("xyz@domain.com"));

eml.Body=“Task has been completed”;

SmtpClient smtpClient = new SmtpClient(“[mail.domain.com](http://mail.domain.com/)”);

smtpClient.UseTnef = true;

smtpClient.Send(eml);

Please assist me on the same as soon as possible.

Thanks in advance,

Vipin Panwar

Hi Vipin,

Thank you for posting your query.

Using the following code sample, I am able to send the email without setting the Task’s start and due date. Could you please make sure if you are using the latest version of Aspose.Email for .NET 5.3.0?

Code:

MapiTask task = new MapiTask();
task.Subject = "Aspose Task Test";
task.Body = "Test Body";
task.PercentComplete = 20;
task.EstimatedEffort = 2000;
task.ActualEffort = 20;
task.History = MapiTaskHistory.Assigned;
task.LastUpdate = DateTime.Now;
task.Users.Owner = "kashif";
MemoryStream ms = new MemoryStream();
task.Save(ms, TaskSaveFormat.Msg);
ms.Position = 0;
MapiMessage mapiMsg = MapiMessage.FromStream(ms);
MailMessageInterpretor mi = MailMessageInterpretorFactory.Instance.GetIntepretor(mapiMsg.MessageClass);
MailMessage eml = mi.InterpretAsTnef(mapiMsg);
eml.From = "username@gmail.com";
eml.To.Clear();
eml.To.Add(new Aspose.Email.Mail.MailAddress("to@aspose.com"));
//IEWSClient client = GetAsposeEWSClient();
SmtpClient client = new SmtpClient("smtp.gmail.com", 587, "username", "password");
client.UseTnef = true;
client.Send(eml);