I want to write C# application which will remotely connect to exchange server and read my inbox! I want to use MAPI for that.
So I got two questions:
Can it be done remotely, and is there any requirements(e.g. install outlook client,etc? )
I was not able to find any code example in C# which uses MAPI to connect to inbox?
1) If I remember correctly Outlook must be installed and a profile must be set up. (In short; you are reading Outlooks data, not Exchange).
2) There are samples for this:
http://bytes.com/topic/net/insights/795371-accessing-inbox-through-mapi-using-c-net
http://g8.cx/mapi/ (See 4.7)
Note that MAPI/CDO is not supported in .Net.
Other options is to communicate directly using WebDAV, IMAP, POP3 or WebServices. All will work to retrieve emails. I recommend you try the webservice.
You can access the mailbox of a user from a remote machine.The email account should be configured on that machine and then you can read the mailbox using Microsoft.Office.Interop.Outlook and this link will provide you more info.
http://msdn.microsoft.com/en-us/library/ff870566.aspx
Why do you want to use MAPI so badly ?
Just use EWS:
http://www.codeproject.com/Articles/399015/Exchange-Web-Services
Related
I am currently working on a program to export/import data from other mail clients to outlook.
So far it seems I have two options available.
I learn how to write to a pst file so I can easily import the necessary data.
I create a different, self-made connection.
I am not asking which one I should use but rather on some advice because so far while planning I ran across a few things with each method that might turn out to be too much of problem.
So far I couldn't find an existing library that allows writing to a .pst file. I am lucky to finally have found a library that allows reading the pst file that is open source.
I haven't found a way yet to programmatically create a new mail item in the inbox. I have been able to create a new email that can be sent but no email yet that is "incoming".
have you looked into outlook interop?
depending on how your application will function it is a great way to interact with outlook at a high level, you can easily create mailItems, calendar, memos etc.
My recommendation would be to create a temporary IMAP account on whatever IMAP server you like best (whether that be GMail, Yahoo!Mail, some other free IMAP account, or a local Exchange/Dovecot/etc server).
Then, once you've got that setup, export mail from Mail Client X to the IMAP server and then add the temporary IMAP account to Outlook and copy them all into your Outlook folders.
I decided to write here, because I have a problem. I would like to get "only" new mail from Exchange Server using WebDav Protocol in C#.
I downloaded "Exchange SDK" from Microsoft website :
http://msdn.microsoft.com/en-us/library/ms878023%28v=exchg.65%29.aspx
There was an article called "Using the Notification Sample Application" which I tried to use. (This SDK use "POLL" Method)
Everything was fine, because I used this code written by Microsoft which shows how to use Notify using WebDav Protocol and use in your application.
When new mail has come, I was able to notify user about this and after that I "Downloaded" or "Retrieved" mails from Exchange Server.
But one thing which strongly frustrating me is that after notified new mail has come, I can only "get" for example : "All mails" from Inbox folder on my Exchange Server, but I would like to be able to "get, retrieve" only "new" mail which came on Exchange Server.
Is it possible to do this ?
I read a lot of articles in internet, and I could not find any satisfy answer for my question.
It would be great if I can read for example "a:href" for new mail.
I would like to get the last unread mail...
Please help me.
Looks like is not easy to work with WebDAV protocol. We had problem with development on Exchange 2003 and at the end decided to buy third party component "WebDAV .NET for Exchange". That makes development easier.
Notifications in WebDAV will not give you HRef, you have to do SEARCH.
I have a barebones c# service installed and want to use the outlook.interop functionallity from within my program. Just to detect and read new emails recieved. I have the program that does this but it is a form application. Is it possible to use outlook.interop from a C# service?
Better avoid using an interactive application within a service environment. Using Outlook from a service is not supported by Microsoft and will get you probably in all sorts of trouble (think message boxes popping up for instance).
If you want to talk to an Exchange server better use CDO/MAPI or the Exchange Web service API.
If you want to talk to a POP3 or IMAP server use a dedicated library.
You should look at the Redemption RDO Library (commercial third-party tool), which is effectively a managed wrapper for MAPI that allows out-of-process access to Outlook stores. To detect new mail, you could subscribe to the RDOStore.OnNewMail event.
I need to avoid forwarding in the emails that I'm sending using .NET. I'm using Outlook and Exchange server and I read tha IRM can help me. Does anyone have any code example or know if it's possible?
It looks like you might be able to use the Microsoft Outlook 2010 Primary Interop assembly and set the PermissionTemplateGuid property of the MailItem you're sending.
Note that you'll have to know the Guid of an IRM policy that prevents forwarding of the email.
You cannot send IRM mail programmatically in Outlook 2010. IRM mail is actually a regular mail message with an encrypted attachment, and Outlook does not expose the right API to craft the encrypted attachment and change the mail type.
The only way to do it from C# code is to use ActiveSync and send the mail in Exchange directly. Unfortunately, as of Exchange 2010, only licensed vendors can use ActiveSync.
See http://www.microsoft.com/about/legal/en/us/intellectualproperty/iplicensing/programs/exchangeactivesyncprotocol.aspx for more information.
Also, if you go down the path of setting the template guid, know that the DoNotForward template guid is hard-coded -- if it actually works (this is untested and unsupported, so you're mileage will vary) then you don't need to bother looking up the RMS template.
is it possible to integrate outlook with my c# program without having Microsoft office installed?
It depends on what functionality you are trying to achieve?
It also depends on your environment.Do you have access to exchange server?
For example, If you want to create appointments in outlook client for individual user, you can very well make use of webservice provided by Exchange server. However, it works starting with outlook 2007.
In a word, no. If you want to call an Outlook dll you will need Outlook installed.
Perhaps if you describe what you need to do there may be an alternative approach, such as calling Exchange Server as suggested by Edwin.