I'm trying to set a MIME Content-Description field in an email. I set the Content-Type and the Content-Tranfer-Encoding using an AlternateView, but I can find no way to add Content-Description.
What I can do is set Content-Description using a custom header, but this appears to insert a single Content-Description for the entire email, rather than for the MIME object.
using( MailMessage mailMessage = new MailMessage() )
{
mailMessage.From = new MailAddress( _configuration.FromAddress );
mailMessage.BodyEncoding = Encoding.UTF8;
mailMessage.To.Add( to );
mailMessage.Subject = subject;
// add the MIME data
var irisB2View = AlternateView.CreateAlternateViewFromString( body );
irisB2View.ContentType = new ContentType( "Application/EDI-consent" ); // Content-Type
irisB2View.TransferEncoding = TransferEncoding.Base64; // Content-Tranfer-Encoding
mailMessage.AlternateViews.Add( irisB2View );
// this adds Content-Description, but it appears before the MIME data
mailMessage.Headers.Add( "Content-Description", "IRIS/B2/Z" );
client.Send( mailMessage );
}
This results in an email of the form below, with Content-Description before the MIME object:
Content-Description: IRIS/B2/Z
MIME-Version: 1.0
From: xxxxxx@xxxxxx.xx
To: xxxxxx@xxxxxx.xx
Date: 28 Sep 2018 13:49:51 +0200
Subject: subject
Content-Type: Application/EDI-consent
Content-Transfer-Encoding: base64
Does anybody know how I can manage to get the Content-Description into the MIME content?
Equally, the mail has no boundaries (I only have one MIME object), so does it actually matter that the Content-Description is before the MIME object?
Thanks in advance.
RFC 2045 specifies that in a single part message the MIME header fields are used in the context of a regular RFC 822 header. RFC 822 does not impose a sequence on header fields. Therefore the placement of the Content-Description field does not matter.