How to send Outlook tasks requests by mail without

2019-03-28 15:53发布

问题:

I need to replicate the Outlook feature/functionnality to send some tasks requests to someone (see here) but with mails sent from a webserver using ASP.NET C# and without Outlook installed on the webserver (thus using outlook automation is not possible).

I already check what are the possiblities to do this, and it seems a common way to send tasks to someone is to generate an .ics file in iCalendar format, and include that file to the mail (see this stackoverflow question).

It works great, however there is no equivalence of tasks sent by outlook :

  • Events (VEVENT) have a start date and end date (like a task) but no "completion" field (which make sense since it is an event, not a task).
  • Todos (VTODO) have only a due date, no start date or end date and it is not supported by outlook.

I checked myself what Outlook exactly send in a mail containing a task request : It include a winmail.dat file (with content-type:application/ms-tnef) encoded as Base64. Inside that file (which is a binary file) there is a reference to IPM.TaskRequest which seems to be what i need.

I checked the web and found some TNEF parsers, but i need the oposite : to generate from C# code a TNEF file that would contains a task request. I would like to know if there is a way to do that. Using a library (free or not) is not an issue.

回答1:

Even if outlook were installed on the web server, outlook automation on a server is generally a bad idea.

However, have you looked at Exchange Web Services? It provides a complete object model to integrate with outlook. Obviously it's tied to outlook (unlike ics), but it does seem to fit your use case.

EWS overview: http://msdn.microsoft.com/en-us/library/exchange/dd877045%28v=exchg.140%29.aspx

Working with tasks: http://blogs.msdn.com/b/dhruvkh/archive/2012/04/06/working-with-tasks-using-exchange-web-services.aspx