RTF message bodies in EML files - c#

We use the LumiSoft.NET MIME library to create EML files. These EML files are constructed by database values. The body of the email can be plain text, RTF, or HTML. We know when the body is HTML so, when that occurs, our EML file's content-type is set with this line:
Content-Type: text/html; charset="utf-8"
When the body is plain text or RTF (because we don't know which it is), we set the content-type to RTF like so
Content-Type: text/rtf; charset="utf-8".
The HTML EML files show up just fine across different products... but the RTF EML files seem to be interpreted differently by different products. This worked for years and our resulting EML files were QA'd against Outlook Express and they appeared normally. But recently we had some customers report issues with these emails showing up with the message bodies as attachments. In Outlook 2007 SP2 and Outlook 2010, the email bodies do indeed show up as TXT files that are attached to the email... and the bodies inside the email itself are empty. Furthermore, we use a product called dtSearch and when it converts these EML files to HTML, it does a similar translation where the body of the EML file is shown in the content of an attachment named Attachment0.DAT. Futhermore, we also process these EML files through Outlook Redemption and, just like Outlook 2010, the message bodies are in a TXT file attachment. So weird behavior across the board... here's some screenshot of it in action.
Outlook Express:
Outlook 2010:
Here's the actual EML file.
Are we doing something wrong here by using RTF for the content type? It seems to have worked in the past and works with Outlook Express. It's been recommended to switch to the MSG format using Redemption instead of EML format to alleviate this but I believe that puts a prerequisite requirement on the user machine of either Outlook or the MAPI library.... but if the EML format isn't parsed the same by different products, then maybe the MSG format is the way to go.

The content of the email does not look like a valid rtf (No magic number "{\rtf").
It's plain text with quoted printable transfer encoding.
You should use content-type: text/plain.

Related

Send email message eml c#

Currently, I have an email application and I want to add send messages with .eml but not as attached file without from, to content. I don't know where to start. My first idea was extract message from .eml file and return CDO message.
It would be possibly looking at the OpenPop.NET library (http://hpop.sourceforge.net/). MIME parsing is included and, as far as I can remember, functioned OK for me once. I have the impression that this is what you are looking for.

C# Mail pdf attachment utf-8

In my application, i send mails to managers from program automatically. Normally it works good, but when i use program on another computer, it sends mail automatically but file type is not PDF. File type is File and name of pdf is =utf-8BQU5HT1JBIEhBTEkgQS7Fni4gR8OcTkzD. I also checked source codes. But I couldn't understand what is wrong with that. Any idea what to do?
Try to fill the ContentDisposition, example is here:
Sending email with attachments from C#, attachments arrive as Part 1.2 in Thunderbird
Maybe, in the code you can change the MediaTypeNames.Application.Octet to MediaTypeNames.Application.Pdf
I hope, this helps!

Read Outlook attachment content in Outlook add-in (C# ) while creating a mail

I am trying to develop an outlook add-in in VS 2010. It's purpose is to scan email body and attachment content for some key words and if any such words are found, email sending should be blocked.
I am able to read email body and subject and to the validation but I am not understanding how to read an attachment content (txt file) while composing the mail.
attachment.GetTemporaryPath() is not giving the attachment path. I guess this works only for mails in inbox.
One way I found was saving the attachment to a temp folder and reading it (attachment.saveAs()).
Is this the only way to read attachment content while composing a mail ?
Possible Duplicate : C# Outlook 2007 - How do I access attachment contents directly from my addin?
But as suggested in there, I cant use Redemption. Is there any other way?
Yes, saving the attachment data to a temporary file and reading it s the only way. In theory, you can use Attachment.PropertyAccessor.GetProperty to read the PR_ATTACH_DATA_BIN property, but you will run into problems for the large (> 64kB) files.
You can also use Extended MAPI to open the attachment data as IStream (IAttach::OpenProperty(PR_ATTACH_DATA_BIN, IID_IStream)), but it is only accessible through C++ or Delphi. You can use Redemption (any language - I am its author) that wraps Extended MAPI and exposes AsArray and AsText properties on both RDOAttachment and the Attachment object exposed by the Safe*Item objects.

Get the outlookItem type of an attachment in outlook

I am getting the attachments from an outlook mail. There are some traps aroudn this from c#, but most of them are solved by some ugly hacks. But there is one that I am not able to solve.
If I add an attachment as a file, the whole filename is saved including the file extenssion. So when I save the file to disc later it's saved correctly so I can only dblclick the file and it's opened in the correct application.
But if the attachement is added using the "Attach Item" -> "Add outlook Item", the mail/calender/contact is added without the file extenssion. So If I add a mail to my mail with this function then the .msg fileextension is not part of the filename and when trying to save it to disc it is recognized as an outlook mail.
But if I check in outlook I can see that the correct icon is added for this attachment, so outlook is able to know if it's a mail / contact / calenderitem so the information should be there somewhere.
Does anybody knows how to find out that it's a .msg that is in the attachment?
When you pass an Outlook item to Attachments.Add, you add create an embedded message attachment (Attachment.Type = olEmbeddeditem) as opposed to the regular olByValue attachment.
BTW, the filename(Attachment.FileName) will always include the .msg extension. What are the cases when it is not there?

How to send .zip in attachment by email on exchange server?

Hell guys,
I'm coding in csharp to send an email which contains a .zip file (has htmls and css inside). When I check the mail recieved, In fact, instead of the .zip file, the attachment becomes a txt file and has:
FILE QUARANTINED
The original contents of this file have been replaced with
this message because of its characteristics.
File name: 'xxxxxxx_Result.zip'
Virus name: 'Large uncompressed size'
The exchange server has blocked the zip file..I'm using CDO to create and send the email.
I tried using the code to send a mail with a zip file generated by WINZIP, there was no problem, then I tried using outlook to send a mail with the zip file generated by my code(I use sharpziplib library), the problem occured...
How can I do to send the attachment correctly? Many thanks in advance!
Allen
I encounter similar problems sending email on our network. I've found that using an alternate compression format, such as 7-zip (.7z), is adequate to get my content through the filters. This could resolve the issue if the block is not due strictly to size.
Looks like your mail server or spam service have removed your attachement and replaced it with the txt file, it sounds like your code is fine and you need to speak to an admin regarding the mail filters and send size quotas!
For anyone facing this problem, here is a solution. You have to explicitly set the file size for the zipentry.
ZipEntry newEntry = new ZipEntry(fileName);
newEntry.DateTime = DateTime.Now;
newEntry.Size = fileData.Length; // setting data size

Categories