Hi Vipin,
Thank you for posting your query.
If you want the Task to be available in Outlook, then you have to do it using the Exchange Client as there is no other way for this to be available otherwise. The ExchangeTask class can be used to initiate such a task and then create it on the Exchange server using the IEWSClient. I would request you to please have a look at our documentation article, Working with Tasks on Exchange Server, for:
- Creating a Task
- Updating a Task
- Adding a Reminder to the task
- Deleting a task
In order to send a Task as an assignment to a user, you have to load it from disc for sending using the SmtpClient or EWS Client of the API. Please try the code sample below for this purpose and let us know if we can be of any help to you.
Code:
// Create instance of ExchangeClient class by giving credentials
IEWSClient client = EWSClient.GetEWSClient(“https:[//outlook.office365.com/ews/exchange.asmx](https://outlook.office365.com/ews/exchange.asmx)”, “testUser”, “pwd”, “domain”);
MailMessageLoadOptions loadOptions = new MailMessageLoadOptions();
loadOptions.MessageFormat = MessageFormat.Msg;
loadOptions.FileCompatibilityMode = FileCompatibilityMode.PreserveTnefAttachments;
// load task from .msg file
MailMessage eml = MailMessage.Load(“task.msg”, loadOptions);
eml.From = "firstname.lastname@domain.com";
eml.To.Clear();
eml.To.Add(new Aspose.Email.Mail.MailAddress("firstname.lastname@domain.com"));
client.Send(eml);