I need to create a very simple c# Windows Service to listen for, and process email wth special subject lines. I already have the code that process these emails working well. For ease of development, I just packaged the code in an "Outlook Addin" on my own machine, running under my own email account. Works great.
Now that it's working, I need to move this to the server. I have a special email account setup on the Exchange Server for this purpose. I really don't want Outlook running on the server. Is there some other way to login to this email account and listen for email from my Windows Service without using the Outlook client?
Thanks!
It sounds like your code is closely tied to Outlook, so you may have to change your approach for the server. I faced exactly the same problem last year and considered the following options :
CDO (not supported by Microsoft with .NET due to some strangeness when running in process)
WebDAV for Exchange 2003
Web Services for Exchange 2007 (great example in the link)
You also need to ask yourself - do you actually need your program to check the mail server? I couldnt use any of the above options so ended up having one of the mail admins set up an exchange rule that dropped the emails/attachments into a special folder on the server. I could then process the files at my leisure. Worked extremely well and much easier to maintain than directly interrogating the mail server through code.
If your exchange admin has enabled it you can use IMAP or POP3 to connect to the server.
You can also use MAPI to connect as well.
You can find a number of libraries (free and otherwise) for doing all three.
I have had good experience with MailBee IMAP but there are definitely free alternatives if you only need to do some simple functionality.
Related
I'm making a simple automation system for someone and require a MQTT admin panel for server/broker. I want it such that the admin who runs the server, is able to see and change the password of the server or client. Also the admin would be able to see the all the topics and remove the subscription of of any client if they want. Admin will also be able to see all the messages sent and received.
I was currently looking at C# MQTTnet and mosquitto but all the servers require manipulation in config files through CLI(there own set of commands on CLI). Isnt there something I can use so that all is done in clean code with WPF form for interface? Is there a solution for this problem? I want a user interface for admin.
Also can a MQTT sever run by a novice user? who has no technical knowledge?
Any reply is much appreciated.
I have never seen a desktop GUI to manage the configuration of a MQTT broker, but you could use something like HiveMQ that bundles an administrative web portal with their package. If there is a web api then you could write API requests from your desktop application to interact with the administration portal.
See: https://www.hivemq.com/blog/restful-http-apis-with-hivemq/
This is just one of a very large number of possible approaches.
I have a C# MVC application. I am using Outlook Interlop to create and open new mail through the application with contents and attachments pre-populated.
I get the desired functionality when I run the application locally on my development machine.
When I deploy the same application to server (2012 R2), the outlook new email window does not open on the client side.
Is is possible to open new outlook email window on client machine with the interlop code running on server. (Every user of the application has Outlook installed on their machine).
I have just installed Outlook 2013 on the server. Is there anything else I need to do on the server to make this work.
Any help would be appreciated as I have been struggling a lot to make this work.
Are there any alternative solutions to achieve the same?
Thanks in advance.
No, firstly, Outlook cannot run in a service such as IIS.
Even if it could, it would still be displayed on the server side.
You can dynamically generate an EML (MIME) message on the server. When the user on the client side downloads it, Outlook will display it. If you want the message to be displayed unsent, make sure you include X-Unsent MIME header (set its value to 1).
Code running on the server makes stuff happen on the server. It works on your dev machine because it's both client and server, it won't work on other people's machines. In addition to that, I believe the Office Interop stuff specifically says it's not for use on a server (for both technical and legal reasons).
If you want to pop up a message pre-populated with some values on a client machine, you do have the option of the mailto link, but I believe it is only plain text with no attachments.
I'm currently tasked with importing a huge number of Emails from proprietary mail system into an Outlook.com account (yes, the web service not the desktop app).
Due to the proprietary nature of the source system and the fact that all emails require custom pre-processing prior to importing them into Outlook.com, any commercial service is not an option. Importing the data into a local Outlook database and then export it to Outlook.com is probably not an option either since this is meant to run server side.
What would be my best option to implement the actual import step that preserves the actual email timestamps as they were when the mail was originally received?
This is not for a large number of accounts but this is how you do it for a single account. I would recommend reaching out to Microsoft for support especially if you are a paying customer that needs to import this data.
According to Outlook.com IMAP is not supported yet. Outlook.com does support ActiveSync. I'm not sure which proprietary mail system you are using but it appears that only method would be to setup ActiveSync on the desktop (Outlook) then add a second account (proprietary mail system) via IMAP, then to drag-drop the contents between the two accounts. This is a common method to migrate email data.
Secondly, you can login into your Outlook account and set it to import 3rd party email. Here is an article showing how to do that, Move Your Mail to Outlook article.
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#
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