Parsing emails and attachments - c#

I have a requirement to parse email messages and upload the email into DB based on certain filters. I have experience writing outlook add-in and it is possible to do this in client side.
But here i think i need to write some plugin in exchange server and parse the email messages there itself. is my assumption right? if so please point me to some tutorial for writing exchange server plugins.

You could probably use my MimeKit library to parse the messages.

Related

Application to access, read & delete mails in my webmail with C#

I have been able to send mails from my own domain successfully. My problem now is that I need to access the account and retrieve all the mails that I receive from postmaster and process the information in the mail.
How can I do this? I have been searching the web but could only find solutions involving third party libraries. .NET doesn't bring an inbuild class that helps with this?
First you need to understand what protocols does the Mail Server in question support.
You can find this by either reading the help that accompanies it or search in Google for that Mail Server. You may also need to set some settings on the server before you can start coding.
After you understood what protocols your server supports, use some of the following:
If you are using a POP3 server, you may fine the following article useful : A POP3 Client in C# .NET
If you are facing IMAP or Exchange server, you may want to the link that Billy Coover gave you: Read MS Exchange email in C#
What type of email server are you working with? If it's exchange, there are some options: Access exchange e-mail in C#
First you can try to dedect what protocols(IMAP/POP3) supported by remote server.
You can try imap_clinet_app.zip or pop3_client_app.zip applications from http://www.lumisoft.ee/lsWWW/download/downloads/Examples/ to connect your server.
If you can connect, then specified protocol supported.
Both application comes with full source code, so if can use IMAP or POP3, you can use that library in your project.

how to create a SMTP server

I have an application that run on server,
I want that my application could received mail in order to start some function.
I would like to know what should I need to do in order to have this capability?
Do I need to build SMTP server? if so, how should I do it?
You can try: http://www.lumisoft.ee/lsWWW/download/downloads/ .
There is SMTP server component what you can use to recieve emails.
Or alternatively there is SMTP server written in C#, you can write message filter for server.
In filter you can access incoming message and do what ever you want with it.
--- Yes also as others suggested will work ok too, you just run simple mail server and get emails by pop3 or imap. Pop3 and Imap components and example applications also included in same link.
You can use IIS6 to receive email and drop it into a specified folder. Your app can then pick up those emails and do whatever it needs to with them.
Active the SMTP service in IIS. It drops emails in the C:\inetpub\smtproot\drop folder IIRC.
Then you just need a Mime parser to read the EML files. I used the one in Lumisoft when I did the same thing.
You could use any Mailserver to receive the mail and have your application check the poxtbox every 1 minute to receive the mails.
When any mail arrived (or special subject as you need), you could execute your code.
For IMAP you could look at this Library
I have previously had some success using the Chilkat POP3 component to programmatically monitor a POP3 account for incoming mail.

Using ELMAH To Send A Daily Digest Email

I've searched online to see if ELMAH can send daily emails and from the reading I've done, the developers say to use the RSS feed instead of emails. See this post for details. My company wants a daily email sent using ELMAH. Does anyone know if this is possible or of any workarounds for sending daily emails with ELMAH?
Where do your log your errors to? Database/ File / RAM? I would imagine that, for all of the back-end storages supported by ELMAH, except RAM, you could easily write a console app to send this daily email summary that you want.
For what is worth, look at the System.Net.Mail.MailMessage and System.Net.Mail.SmtpClient classes on MSDN.

How to programatically get ALL (read and unread) messages from gmail, read status, etc?

I have a customer service web app requirement, which requires that I work pull & integrate data from Gmail, eBay, Amazon, and Paypal. My solution is going to be developed in ASP.Net 4 with C#.
The issue that I'm running into is that my client needs pretty much all of the information that Gmail has about each and every email that comes in & the ATOM feed coming from Gmail seems to be a bit lacking. I realize I can also use POP3 or IMAP, but they too are lacking for a number of reasons.
Specifically, the client needs the read status of emails (whether or not THEY have read emails that were sent to THEM). They also need for all of the filters to remain intact. So if an email is tagged with x,y, & z, then I need to know about it.
The ATOM feed only shows me unread emails, so that's out.
POP3 has no clue (and rightfully so) whether or not they've read an email or not (unless I pull it into a database and manage read status, myself...but that doesn't work if they actually read a mail from within gmail itself).
IMAP seems like it would give me everything I need, but I'm not 100% sure on that. What do you all think? Also, IMAP is SOOO slow. Is anyone aware of any decent libraries that are fairly fast. We're talking about a customer inbox with some 360,000'ish messages at the present time, & the client would prefer to keep those messages at gmail & not work with a disconnected database.
Thoughts / Opinions?
IMAP does provide read/not-read status for each message and you can pull from particular 'labels' (folders) or just pull from the 'all messages' bucket. You don't need to pull the entire message either, you can ask for headers only, giving you the ability to quickly scan many emails.
I've been working on a program to pull my entire gmail dataset down for my own tinkering and processing. I'm using linux, and while there are a multitude of imap 'mirror' and imap 'processing' applications out there, I just want to play with the data, being able to do what I want with it, without stuffing it back into an imap server locally. It's been working decently and I'm using the email's UID (modified slightly) as a file name to dump the headers & email data. Of course, you could massage the data and update a database or whatever at that point, I'm just stashing it for post-processing later. Looking for trends in my email, mostly tinkering.
I tried using the etpan libraries for IMAP processing, didn't find them to my liking, so I've been pulling imap routines from other email programs and servers to play with. I have the RFC's, but really really trying to not reinvent the wheel here if I can help it.
Yup, not the best answer, but hopefully some information to help. I imagine there are nice libraries for PHP, or other web-based systems, I've been working with C++/C myself.

EWS: How to upload attachment first before sending an email?

I use Exchange Web Service API to do sending email. It is very easy to add attachments by just writing
message.Attachments.AddFileAttachment(attachmentname);
The problem is attaching process happens in sending process. I found that yahoo, gmail and hotmail they all uploading attachmetns first before you sending the mail. How to do so?
It's the EWS Managed API which does this uploading and sending in one process. But in the background, multiple requests are made to the Exchange server:
Create the message in the Drafts folder of your mailbox
Upload the attachments
Send the items.
If you want to, you can do this yourself. But I don't see the point in doing that. What do you want to accomplish?
If you notice, GMail for example does not use the same manner of attachment. For instance, when you attach something, I am guessing the files get uploaded to some server and then they just provide you with a Link for the download. So I think you can upload the file to some server (be it FTP, or just a database) and then just add the links to the download of the files in the body of the email.
Good luck. I will be looking into the thread to see if there is in fact a way to do this.
Hanlet

Categories

Resources