在 .NET 中将 Content-Description 添加到电子邮件
Adding Content-Description to email in .NET
我正在尝试在电子邮件中设置 MIME Content-Description 字段。我使用 AlternateView 设置了 Content-Type 和 Content-Tranfer-Encoding,但我找不到添加 Content-Description.
的方法
我能做的是使用自定义 header 设置 Content-Description,但这似乎是为整个电子邮件插入一个 Content-Description,而不是为 MIME [=35] =].
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 );
}
这会产生如下形式的电子邮件,在 MIME object 之前带有 Content-Description:
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
有谁知道如何将 Content-Description 放入 MIME 内容中?
同样,邮件没有边界(我只有一个 MIME object),所以 Content-Description 在 MIME object 之前真的重要吗?
提前致谢。
RFC 2045 指定在单个部分消息中,MIME header 字段用于常规 RFC 822 header 的上下文中。 RFC 822 不对 header 字段强加顺序。因此 Content-Description 字段的位置无关紧要。
我正在尝试在电子邮件中设置 MIME Content-Description 字段。我使用 AlternateView 设置了 Content-Type 和 Content-Tranfer-Encoding,但我找不到添加 Content-Description.
的方法我能做的是使用自定义 header 设置 Content-Description,但这似乎是为整个电子邮件插入一个 Content-Description,而不是为 MIME [=35] =].
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 );
}
这会产生如下形式的电子邮件,在 MIME object 之前带有 Content-Description:
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
有谁知道如何将 Content-Description 放入 MIME 内容中?
同样,邮件没有边界(我只有一个 MIME object),所以 Content-Description 在 MIME object 之前真的重要吗?
提前致谢。
RFC 2045 指定在单个部分消息中,MIME header 字段用于常规 RFC 822 header 的上下文中。 RFC 822 不对 header 字段强加顺序。因此 Content-Description 字段的位置无关紧要。