How to send Outlook tasks requests by mail without Outlook? - c#

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.

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

Related

Synchronize my asp.net application with Google calendar, outlook calendar and other main stream calendar services

I have to create an application that needs to synchronize with Google, outlook or any other popular calendar services. It need to be two way meaning updates and events from google/outlook calendar needs to be visible and editable in my application and vice versa.
I have been searching for a while in hope to find something like Email services that can be synchronized using Imap and Smtp servers.
I found out that .ics file can be used to export and import calendar data. But in my case it need to be real time synchronization from both sides.
Are there any APIs or libraries i can use? Or any other way to do it?
Any suggestion is welcome.
Thank you.
The de facto way to synchronize calendars is a CalDAV server, which reads and writes events to a local database and exposes the event details through the ICS format, wrapped in CalDAV messages.
Various clients have differing levels of support for the protocol and its extensions.
Apple iCalelndar, Mozilla Thunderbird with Lightning and Microsoft Outlook with some proprietary plugin can talk CalDAV, but each have their specific annoyances. iCalendar will refuse to remove conflicts, Lightning will get stuck with authentication issues and stop updating and the Outlook plugins, well ... suck.
One Outlook plugin in particular was designed by a developer (literally 20 tabs in the settings screen), didn't implement base64 properly (we had to pad its messages at the server) and refused to do anything useful when a debugger was active on the machine it ran on.
But that was the state of things like five years ago, and I haven't touched the subject since. I think we settled on using a Google Calendar and provide a one-way sync through ICS files.

How do I load prepared message, with attachments, into user's default mail client?

How do I load prepared message, with attachments, into user's default mail client?
I went looking around for answers to that, and found:
Using Process.Start() with a "mailto:" url won't work, because mailto: doesn't support attachments (except in Outlook, and I can't rely on Outlook being the default client.)
This Code Project MAPI wrapper won't work, because it apparently blocks the app.
Then there's this MAPI Wrapper, which apparently does not block the app, but it changes the current directory, and that breaks a number of things in our app, some of which are running in different threads, so I can't rely on just changing it back.
And after trying out the above, and discovering the current directory issue, I ran across this blog post, which blamed the issue on the MAPI stub library,
And that directed me here, which pointed out that the MAPI stub library is deprecated.
Which leaves me asking:
Is there a way, in a C# application, to create an email message that includes attachments, and load it into the user's default mail client, that does not depend upon the client being Outlook, doesn't block the UI of the app while running, doesn't change the current directory of the app out from underneath it, and doesn't rely on deprecated and soon-to-be-removed system libraries?

Creating and showing e-mail on Windows with maximal e-mail client compatibility

I need to create an executable that can be called from the command line which will create an e-mail, attach files to the e-mail and show the e-mail to the user so that they can complete the e-mail and send it. This should be done in the e-mail client that the user has configured as their default.
This needs to work for as many e-mail clients as possible. The ones I'm aware of that are used most are Outlook 2007-2010, Outlook Express, Windows Live Mail and Thunderbird. I'll target .NET 2.0 so that it does not require a newer .NET to be installed if the user is using Vista.
Simple MAPI is capable of doing the above, but Outlook 2007+ does not support it. All the other mail clients on the list do support Simple MAPI. I get the impression that Outlook is the only client that uses Extended MAPI and that Extended MAPI is tricky to use, so it's better to just use the Outlook COM API instead of Extended MAPI.
First the program will look for Outlook and use the Outlook COM API to perform the above if Outlook is available. I'll implement this component in VB and use late binding so that I'm not compiling against a specific version of Outlook. Then, if Outlook is not found it will fall back to Simple MAPI and attempt to use it.
Because of all this decision-making in the code I'll make this program log its activity so that we can debug what is happening on the user's machine when it doesn't work.
Will this approach work? Do you know a better approach? My goal is to maximize compatibility.
EDIT
It looks like Outlook 2007+ does support Simple MAPI, but if you're running the 64 bit version then a 32 bit executable can't call it. I'll stick with the above plan for that reason.
Outlook 2007 supports Simple MAPI just fine.

How do I access Outlook mails with ASP.NET?

I'm trying to write an asp.net (using c#) app that accesses my Outlook mailbox and display the messages. I searched on google but couldn't find useful info, any help is appreciated?
You must be aware of the fact that outlook is running on user local machine, and your ASP.NET application is running on some server and there is no way that your server side ASP.NET code can use Outlook local data.
AFAIK only way to do something like that would be creating outlook addin that will export all mails to ASP.NET application
If you are using Exchange then you can use Exchange Web Services to read emails.
Please see here
Be very careful that you do not attempt to access Outlook on the server side by using the Automation interfaces. All of the Microsoft Office desktop applications are written to be run by an interactive user in a process with a message pump, with all synchronization happening via the UI. When you run them in a multi-threaded environment like ASP.NET, horrible things will happen. If you're lucky, the application will simply crash.
If you're not lucky, you can suffer from data corruption, random crashes in unrelated code, and all the other things that happen when an application corrupts memory.
You may also violate your license if the people accessing the Office application through your web site are not individually licensed to use the application on their desktop.
You can't connect to Outlook via C# (ASP.NET), but you can connect to your mailserver via POP3/IMAP to read the mail.
IMAP Client library using C#

How should I go about getting and processing an (Exchange) email attachment?

I need to get a zip file from an email attachment, unzip it and copy it somewhere.
What would be the way I should go about it?
I'm currently googling around things like 'Exchange API' and 'processing email attachments' and kind of hoping this kind of thing has been done before.
The environment will be Windows and Exchange 2003, and any coding will preferably be in C#.
I had to do this some time ago, and the best way is to use WEBDAV. Every mail item can be referenced like a URL.
If you check out this blog post on WEBDAV, it should show you the way.
I did this in the end using Redemption I had a couple of problems, hence the linked question but got there in the end.
You do need to have the Outlook client installed, and you need full mailbox rights (not just read) on whatever mailbox you are trying to access.
This question, Read MS Exchange email in C# asked a couple of weeks after mine got some good answers as well.
Assuming you want to do this in .NET you will either have to write or purchase a POP3 or IMAP4 class library to communicate with the Exchange server.
Here is one example of a POP3 client from CodeProject:
http://www.codeproject.com/KB/IP/despop3client.aspx

Categories