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