Archived Forum Post

Index of archived forum posts


Email.AddRelatedHeader does not work anymore

Sep 01 '15 at 06:00

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.


Accepted Answer

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.