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.
Related
I have developed (using C#) an Outlook add-in, which implements some rules on client side.
It receives each incoming mail, and if it fits some rules it locates it in a specific folder. The main issue is that it works fine, only when outlook client is open on user pc. If it is closed it does not work, because it is triggered on client's pc.
I wonder if it can get developed or moved somehow on server side (Microsoft 365 Exchange Server), so it works 24/7.
How complicated is the logic in code you have written ? eg a lot of the logic your talking about can be done in Office365 using Flow without needing to write any code (you can even write custom connectors for more advanced logic). You won't be able to use the Outlook code you have written but you can do the same thing using either the Microsoft Graph API and Webhooks to listen to incoming email and then use the Graph operations to perform whatever logic you have (host the app on Azure etc or even can be a server-less function hosted on Azure or AWS) or using EWS Notifications https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/notification-subscriptions-mailbox-events-and-ews-in-exchange
I have been working with EWS Managed API and have frequently come across posts for Assign Task or Task Requst creation is not supported by EWS.
http://social.msdn.microsoft.com/Forums/exchange/en-US/53418cb8-9fb8-4f4d-9bcf-d314909e9eb9/create-task-request-using-ews?forum=exchangesvrdevelopment
http://social.msdn.microsoft.com/Forums/exchange/en-US/82574974-890b-4c13-849f-73f111906b98/send-a-task-request-using-ews?forum=exchangesvrdevelopment
But we can create Task Requests from Outlook. How does Outlook do that? What API does it use in the back to achieve this?
Is there a way to use the same API that Outlook uses to achieve this functionality?
Outlook internally uses Extended MAPI (accessible in C++ or Delphi only).
You can use the Outlook Object Model or Redemption (I am its author), which wraps Extended MAPI.
If you need to build a task request without using the MAPI system in one form or another, you would need to build a winmail.dat attachment, which is a TNEF stream containing MAPI specific properties used by task requests.
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
I write system, that collects informations about local system. It's a system like admin-client. Client collects and sends log to admin. There's of course possibility to get this log by admin over LAN, but I'd like to add option send log over Internet.
I thought about skype. Client must have logged skype and when admin (of course there must be appropriate authorization, but it's separate topic) send request by skype - client must e.g. connect to SQL database or simple file with collected log and send it over skype.
How can I do this?
Is this the best way? Plugin in skype? What lib may I use?
I think it's an either/or situation.
If you want an administrator who is already using Skype to be able to send this information over the internet, then a plugin which exposes that functionality in Skype is the way to go.
If you want the administrator to be able to send the information over Skype's network, but not necessarily have to have the application running (perhaps this will be done through the application that gathers data), then using the API to control Skype externally is better.
You can find the documentation for Skype here:
http://developer.skype.com/accessories
Skype has a COM API called Skype4COM which you could use through COM interop in order to access Skype.
It should be noted that SkypeKit is now available for use in both embedded and desktop programs. There's a small one-time registration fee (currently $5 USD) for each program, but it will allow you to access Skype without actually using any UI functionality (it's completely up to you to provide the interface).
Until SkypeKit is released, you're limited to the Skype Public API. However according to the docs this API only allows to specify the recipient and open the file dialog, initiating a file transfer automatically seems to be impossible (see "OPEN FILETRANSFER" in the docs).
I suggest you use an open protocol like HTTP or FTP instead.
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.