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

Free Support Forum - aspose.com

Error trying to save Outlook Task

Hi,

I am trying to create an Outlook task and email it out, The task gets created correctly and the email is sent out correctly. The requirement is for the user to be able to click on the attached task and then copy it to their local outlook client.

When opening and clicking on copy to folder the following error is thrown!
“A resource is busy or you lack sufficient access rights or permission"

Please see word file attached with screen shots of the error.

The code I have used is as follows.

try
{
MapiTask task = new MapiTask(“To Do 1”, “Just click and type to add new task”, DateTime.Now, DateTime.Now.AddDays(3));
task.PercentComplete = 20;
task.EstimatedEffort = 2000;
task.ActualEffort = 20;
task.History = MapiTaskHistory.Assigned;
task.LastUpdate = DateTime.Now;
task.Users.Owner = “Darius”;
task.Users.LastAssigner = “Harkness”;
task.Users.LastDelegate = “Harkness”;
task.Users.Ownership = MapiTaskOwnership.AssignersCopy;
MemoryStream stream = new MemoryStream();
task.Attachments.Add(name: “Test attachment.docx”, data: File.ReadAllBytes(path: “D:\documents\New Microsoft Word Document.docx”));
task.Save(stream, TaskSaveFormat.Msg);
stream.Position = 0;

//Create an Instance of MailMessage class
Aspose.Email.Mail.MailMessage message = new Aspose.Email.Mail.MailMessage();

//From field
message.From = "user@gmail.com”;

//To field
message.To.Add("someone@somewhere.com");

//Adding 1st attachment
//Create an instance of Attachment class
Aspose.Email.Mail.Attachment attachment;

//Load/Add an attachment
attachment = new Aspose.Email.Mail.Attachment(stream, “Task.msg”);
message.AddAttachment(attachment);

//Create an instance of SmtpClient Class
Aspose.Email.Mail.SmtpClient client = new Aspose.Email.Mail.SmtpClient(“smtp.gmail.com”, 587, Aspose.Email.SecurityOptions.Auto);
client.Password = “mypassword”;
client.Username = "user@gmail.com";

try
{
//Client.Send will send this message
client.Send(message);

//Display ‘Message Sent’, only if message sent successfully
Console.WriteLine(“Message sent”);
}
catch (System.Exception ex)
{
System.Diagnostics.Trace.WriteLine(ex.ToString());
}
}
catch (System.Exception ex)
{
}

Regards and Thanks

Hi Arlene,

Thank you for contacting Aspose Support team.

We have tested this issue at our end and were not able to reproduce it using the latest version of the API i.e. Aspose.Email for .NET 6.1.0. Can you please confirm to us if you are using the latest version of the API and still getting the problem? We shall further investigate the issue in light of feedback shared by you.

Hello Muhammad,

Yes we are using the latest version 6.1.0.0, I have no difficulty creating the .msg file, its only an issue when I try to open and copy the task to the Task folder within Microsoft Outlook.

I have tried using both MapiMessage and MailMessage with no luck

public void Email()

{

try

{

MapiTask task = new MapiTask(“To Do 1”, “Just click and type to add new task”, DateTime.Now, DateTime.Now.AddDays(3));

task.PercentComplete = 20;

task.EstimatedEffort = 2000;

task.ActualEffort = 20;

task.History = MapiTaskHistory.Assigned;

task.LastUpdate = DateTime.Now;

task.Users.Owner = “Darius”;

task.Users.LastAssigner = “Harkness”;

task.Users.LastDelegate = “Harkness”;

task.Users.Ownership = MapiTaskOwnership.AssignersCopy;

MemoryStream stream = new MemoryStream();

task.Attachments.Add(name: “Test attachment.docx”, data: File.ReadAllBytes(path: “D:\documents\New Microsoft Word Document.docx”));

task.Save(stream, TaskSaveFormat.Msg);

stream.Position = 0;

//Create an Instance of MailMessage class

MapiMessage msg = MapiMessage.FromStream(stream);

// 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);

Aspose.Email.Mail.MailMessage eml = mi.InterpretAsTnef(msg);

eml.From = "someone@gmail.com";

eml.To.Clear();

eml.To.Add(new Aspose.Email.Mail.MailAddress("someone@hubsolutions.co.uk"));

Aspose.Email.Mail.MailMessage message = new Aspose.Email.Mail.MailMessage();

//From field

message.From = "someone@gmail.com";

//To field

message.To.Add("someone@hubsolutions.co.uk");

//Adding 1st attachment

//Create an instance of Attachment class

Aspose.Email.Mail.Attachment attachment;

//Load/Add an attachment

attachment = new Aspose.Email.Mail.Attachment(stream, “Task.msg”);

message.AddAttachment(attachment);

//Create an instance of SmtpClient Class

var smtpClient = new Aspose.Email.Mail.SmtpClient(host: “localhost”);

smtpClient.AuthenticationMethod = SmtpAuthentication.Auto;

smtpClient.DeliveryMethod = Aspose.Email.Mail.SmtpDeliveryMethod.Network;

try

{

[//Client.Send](https://client.send/) will send this message

smtpClient.Send(message);

smtpClient.Send(eml);

//Display ‘Message Sent’, only if message sent successfully

Console.WriteLine(“Message sent”);

}

catch (System.Exception ex)

{

MessageBox.Show(ex.ToString());

}

}

catch (System.Exception ex)

{

}

}

I am also attaching the msg file that gets emailed, you can try opening it using outlook at copying to the Task folder and you should be able to reproduce the problem.

Also please note that I am attaching a Word file to the task, I initially thought that this was the issue, but even if there is not attachment associated with the .msg file I am still unable to perform the required action using Outlook.

Regards

hubsol.

Hello Muhammad,


Another strange issue is that the .msg files if physically saved to a file and then opened from outlook manually, they work fine, but if I email the task file and try opening them or copying them to the task folder in Outlook then I get permission error.

Regards
hubsol

Hi Arlene,

We have again tested this issue at our end by sending a sample task using the code sample you have shared above. The email is opened from within MS Outlook and the task is copied/moved to “Tasks” folder. This we have tested with both MS Outlook 2007 and 2013, and no problem occurs at our end as can be seen in screenshot.

Hi Kashif,


Thanks for your help, I am not sure why I am unable to open move / copy the emailed task to the Task Folder.

I will investigate further and get back to you if I require your help.

Regards

Hi Kashif,


Could you please email me the sample project that you created, might be worth trying that out and seeing where I am going wrong.

Many Thanks

I have also uploaded a screen cast of the error

http://screencast-o-matic.com/watch/cDVt6ihKyo

Hi Arlene,


I have re-produced the issue here and have logged it under Id: EMAILNET-35106 in our issue tracking system for further investigation by the product team. I shall write here as soon as some feedback is received in this regard.

Hi Arlene,

We have completed our investigation and come to know that this behavior is similar to the tasks created by MS Outlook and, thus, is not an issue with our API. Please feel free to write to us if you have any further query related to the API.