login about faq

Hi,

I have a problem handling attached messages (MSG) in an email. I use Chilkat 64-bit .NET 4.5 version 9.5.0.54.

Question 1: When I received an email from Outlook 2013 with an attached email message the number of attachments properties for the Email object are like this: NumAttachments is 0 NumAttachedMessages is 1

When I create an email from Outlook 2015 with an attached email message I have the following: NumAttachments is 1 NumAttachedMessages is 1

Have you seen this before?

Question 2: Furthermore, the filename of the attached email message is always "attachedFile.mht" even though the original filename is different. What is happening?

Question 3: When I have more attachments to an email (1 PDF file and 1 email messages) I have trouble getting data by attachment index. Some indexes are defined as "the Nth attached (embedded) email" and others as "the Nth attachment". Is it possible to distinguish between indexes of attached files and attached messages? For instance an attached message can both be the first attached message but the second attachment. This is confusing.

Hope you have time to answer my questions.

Best regards Kristian

asked May 20 at 04:51

khn's gravatar image

khn
1


It's only possible to answer questions like this if the MIME source of the email can be viewed. I'll try to answer as best as possible without seeing the MIME source.

  1. An email sub-part can be deemed both an attachment and an attached message. I believe this can happen if certain conditions strongly suggest the semantics of an attachment, such as "content-disposition: attachment", and at the same time the sub-part has a content-type of message/rfc822. To get a glimpse of the internal logic followed to determine if something is an attachment or not, you can turn on verbose logging by setting the Email.VerboseLogging property = true, then access the Email.NumAttachments property, and then examine the Email.LastErrorText. You will see the decisions making process within the LastErrorText.
  2. Looking at the MIME source would answer this question. There can be a "filename" attribute on the Content-Disposition header, and there can be a "name" attribute in the Content-Type header. My guess is that the original filename is either not present at all in the sub-part's header, or maybe it's only in the "name" attribute, but no "filename" attribute exists.
  3. If an email sub-part is both an attachment and an attached message, then it will be in both indexes. In the attachment index (0 .. email.NumAttachments, email.GetAttachmentData, email.GetAttachmentString, etc.) you access the raw bytes or text. In the attached message index (0 .. email.NumAttachedMessages, email.GetAttachedMessage) you can access the attached messages as Email objects. There is a method named email.GetAttachmentContentType(index). You could use this to ignore "message/rfc822" attachments when your app is processing attachments because you'll handle those when processing the attached messages.
link

answered May 20 at 08:53

chilkat's gravatar image

chilkat ♦♦
11.8k316358420

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×18
×6

Asked: May 20 at 04:51

Seen: 245 times

Last updated: May 20 at 08:53

powered by OSQA