Manipulate and process email - c#

I am using Thunderbird and I need to somehow manipulate and process the e-mails that are stored in inbox.msf file using C# language. In C# I am using SS2.Pop3 library.So, I was wondering, how do you parse an .msf file?

.msf files are mail summary files and do not contain emails (admittedly, it's been like 10 years since I looked). Thunderbird uses standard UNIX mbox formatted files to store mail.
There is only 1 parser for those files available in C# and that is MimeKit (which also happens to be my library).
I'm pretty sure that if you have an Inbox.msf file, right next to it should be a file called Inbox which has the actual mail in it. That's the file you want to parse.

Related

.msg to .eml file using Aspose.Email missing Calendar data

I am trying to convert from .msg to .eml file format using Aspose.Email for .NET. Pretty trivial:
var msg = MapiMessage.FromFile(#"example.msg");
MailMessageInterpretor mmi = MailMessageInterpretorFactory.Instance.GetIntepretor(msg.MessageClass);
MailMessage eml = mmi.Interpret(msg);
eml.Save(#"example.eml");
If its a calendar invite, I see it in the .msg file and also in the .eml file, as shown below (.msg on top, .eml on the bottom):
It also includes the meeting .ics file within the .eml it produces:
Content-Type: text/calendar; method="REQUEST"; name="meeting.ics";
charset="utf-8" Content-Transfer-Encoding: base64
However, the problem is that if it is a meeting cancellation instead of an invitation:
The resulting .eml as you can see, does not include meeting details, nor does the resulting .eml contain any trace of a meeting .ics (which does exist in the .msg). I can parse the .msg for it easily:
MapiCalendar calendar = (MapiCalendar)msg.ToMapiMessageItem();
Why is it not base-64 encoding the .ics for cancellations in the resulting .eml? Am I doing something wrong? Is it an Aspose bug? Is it normal behavior? What's going on here?
Could you please share your input/output files with us on Aspose.Email forum? We need to understand what steps are you taking that gives raise to this issue and will further assist you in the forum. If we find it to be a bug with the API, we'll log it for investigation by our Product team.
I work with Aspose as Developer Evangelist.
Edit:
Please try mmi.InterpretAsTnef(msg). Though it should work with Interpret as well, but it seems an issue with the API. We're investigating the problem at our end, however, you can use the InterpretAsTnef meanwhile. You may register on www.Aspose.com free of cost. Our basic support is free for all whether it is paid or non-paid users.

Replace attachment in Outlook with zipped version possible?

Is it possible to create a .Net application which can read my Outlook mailbox, and for each mail replace any attachment with its compressed replacement?
In short, the .NET application/addin should check my old mails one by one, if it has an attachment file, then zip it, and replace the original attachment file with the new zipped one.
This is to reduce the size consumed in my mailbox. is there any such tool already available online?
I am using .Net 2008/2012 and Outlook 2010.
yes, there are a few components available to work with outlook, popular ones: Redemption, Outlook Interop
To achieve what you said, should be fairly simple, retrieve the email and do whatever you like and save it.
Question off the topic: zip the attachments could reduce your mail size, but it will still be large sooner or later... why not think about other ways, for example, archive your emails and etc.?
Could not find exactly what I need, so started creating one. Here is the attempt - http://www.saurabhkumar.com/autozip/ It compresses(zips) mail attachments, just before the mail is sent. Saves the sender and recipient lots of headache.

Parsing and extracting HTML and Text messages from raw .eml file

I did this before, but the source codes were in a flash memory which one failed. So I'm rewriting the project. I've got archived .eml files on disk and I need to extract HTML message if any. If not, I'll extract text message.
I don't remember what 3rd party used before. But parsing was so easy like below:
oMessage.Raw = LoadFile(fileEml);
msgHTML = oMessage.HTML;
msgText = oMessage.Text;
Can anyone recognize that 3rd party library?
I don't know what parsing library you were using before, but the best parser out there right now is MimeKit. It's significantly faster and more RFC-compliant than any other parser.
I'm also working on a mail client library (SMTP, POP3 and IMAP) called MailKit.
(Disclosure: I wrote MimeKit and MailKit after spending time looking at all of the Open Source alternatives out there and finding that all of them were really bad, and often the authors of said libraries blamed the other mail software when it was a bug in their own code and they would have realized that if they actually bothered to read the RFCs.)

Display a saved .msg message as HTML or ASP.NET

I have a problem. I need a way to import a saved .msg file from Outlook and then display this as html.
Ideally I would have an ASP:FileUpload control that the user would upload the email. Then I would want to parse this as markup so the email can be displayed in the website. I just don't know how to go about pulling this email message in and passing it as a new MailMessage object.
If I could bring the data from the file upload in as a new MailMessage object I would imagine I could read the information from the file and display this.
There has to be a way to display the contents of a .msg with C#. I can't imagine there isn't. I would REALLY like to not use third party plug-ins or .dll files. I have a feeling C# has this functionality somehow built into it. (maybe include one of the references?)
Have you considered using a third-party library to load the MSG file, and then retrieve the content of the message? Aspose.Email can probably do that for you.

Reading email from a mail file

I have a huge number of mail archives that I want to de-duplicate and sort out. The archives are either in mbox format or contain a single mail message. To add a bit of complication, some of the files have windows EOL sequences, and some have the unix EOL.
Using C#. how do I read an archive and split it into its individual messages, or read a single message file? In python, I would use the mailbox.mbox class, but I cannot see the matching functionality in the C# documentation.
It is unlikely that you will find a library to read that file for C# - there aren't that many Unix users who also use C#.
What I would do would be either to:
Read the Python code, and then port it to C#
Find the description of the mbox format online. As it is a Unix system, chances are that the format is just a plain text file, which should be easy enough to parse.
Most standard Unix mail files delimit entries with a line starting "From "
So if you read in the mail file as a text file and switch to a new mail entry every time you see the string "From " at the start of a line it should work
- Any strings elsewhere should already have been delimited by the email program
If it one-time activity I think easiest steps to sort messages:
join all the mbox files into one
load compilation into thunderbird as local folder
run one of Duplicate message finder Add-On on folder
delete found dupliates
compact folder
take the dup-free message list :)
Duplicate Elimiators (Add-Ons for Thunderbird)
I've used this: Remove Duplicate Messages (Alternate)

Categories

Resources