login about faq

We are using NuGet package of x64 library for C#.

We've noticed this in, but the bug is still present in

Consider this simple piece of code:

var email = new Email();
email.AddRelatedString("foo.txt", "this is some related content", "utf-8");
email.AddRelatedHeader(0, "FooBar", "some value");

In generated MIME, the "FooBar" header is missing:

MIME-Version: 1.0
Date: Mon, 10 Aug 2015 17:00:44 +0200
Message-ID: <D0FAE0A0BCC353A2410D8D2A06B53E607707459F@MS0PC>
Content-Type: multipart/related; boundary="------------050504020908070905040803"

X-Priority: 3 (Normal)

Content-Type: text/plain; name="foo.txt"
Content-Transfer-Encoding: quoted-printable
Content-ID: <CID-7450f0b0-6679-6048-6d75-4e3bc62c8607@MS0PC>

=EF=BB=BFthis is some related content

While it works perfectly well in

Date: Mon, 10 Aug 2015 17:02:57 +0200
Message-ID: <5560A59B57F441FBCFFE7930E0B7BE54562EEF09@MS0PC>
Content-Type: multipart/related;
X-Priority: 3 (Normal)

Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Content-Type: text/plain; name="foo.txt"
Content-Transfer-Encoding: quoted-printable
Content-ID: <CID-cd3fe3ae-07e9-6017-511f-2f636d4c8414@MS0PC>
FooBar: some value

=EF=BB=BFthis is some related content

Is there any chance of fixing this? This really holds us from upgrading the library to the most recent version. We use "AddRelatedHeader" to substitute auto-generated "Content-Id" headers with our own, but, as you can see, it does not work with any header.


asked Aug 10 '15 at 11:20

marcin_synak's gravatar image


Sadly, v9.5.0.52 does not fix this problem.

(Aug 28 '15 at 10:16) marcin_synak

Related items are the images, style-sheets, etc. that are referenced by the HTML body of an email. An email that has HTML situated under the multipart/related umbrella has this format

    HTML body
    image A
    image B

The structure of the MIME you created does not conform to this pattern. In the example I gave above, image A is the 1st related item at index 0. Image B is the 2nd related item at index 1. When Chilkat finds the Nth related item, it skips the very 1st sub-part under the multipart/related umbrella because that SHOULD be the HTML body (not a related item).

The true issue with the AddRelatedHeader method is that it SHOULD be a method returning a boolean true/false value to indicate success or failure. Unfortunately, it's a void function.


answered Aug 28 '15 at 12:59

chilkat's gravatar image

chilkat ♦♦

PS> The new version does not automatically add the text/plain body. The automatic adding of the body is why it worked in the previous versions. However, when the body is added, it may be that programs don't WANT the empty body for one reason or another. A fix is to add the HTML body, even if temporarily a string such as "This is a temporary HTML body", prior to adding related items.

(Aug 28 '15 at 13:03) chilkat ♦♦

The example above was just the simplest code I could create to illustrate the issue. What we really have is HTML content with embedded images added as related contents (using "AddRelatedData" method). And it is now impossible to add/substitute headers in those related content parts.

I suspect the issue is that we (for some internal reasons) first add images and then set the HTML body. If it was the other way around, it would probably work.

If having first an HTML content you can actually relate to is a requirement, why I can still execute e.g. "AddRelatedString" method and it works?

(Aug 28 '15 at 13:16) marcin_synak

Thanks for the help. I was able to fix my issue by modifying the workflow a bit. It used to be: 1) AddRelatedData (add attachments) 2) AddRelatedHeader (fix headers) 3) Set HTML body

Now it's: 1) AddRelatedData (add attachments) 2) Set HTML body 3) AddRelatedHeaders (fix headers)

It's sort of a chicken-egg problem. For email to make sense, you should first have an HTML body and then related images. But to make a proper HTML, you need CIDs, which you get by adding related images...

(Sep 01 '15 at 06:00) marcin_synak
Your answer
toggle preview

Follow this question

By Email:

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



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



Asked: Aug 10 '15 at 11:20

Seen: 565 times

Last updated: Sep 01 '15 at 06:00

powered by OSQA