如何使用 MimeKit change/set 分离签名的 ContentType?
How do I change/set the ContentType of a detached signature with MimeKit?
使用 MimeKit 签署电子邮件时,ContentType 设置为 application/pkcs7-signature。
我们的第三方提供商要求将 ContentType 设置为 application/x-pkcs7-signature。
在使用带有 MimeKit 的分离签名 签署电子邮件时,是否有一种简单的方法 change/set 此 ContentType?
虽然 ContentType 对象是只读的,但 MediaSubtype 属性 不是。
所以使用以下内容,我可以添加我们需要的 x- 前缀。
var part = SourceEmail.BodyParts.First(x => x.ContentType.MediaSubtype == "pkcs7-signature");
part.ContentType.MediaSubtype = "x-pkcs7-signature";
我还更新了邮件的整体内容类型。
var header = SourceEmail.Body.ContentType.Parameters.FirstOrDefault(x => x.Name == "protocol" && x.Value == "application/pkcs7-signature");
header.Value = "application/x-pkcs7-signature";
为清楚起见省略了错误检查。
使用 MimeKit 签署电子邮件时,ContentType 设置为 application/pkcs7-signature。
我们的第三方提供商要求将 ContentType 设置为 application/x-pkcs7-signature。
在使用带有 MimeKit 的分离签名 签署电子邮件时,是否有一种简单的方法 change/set 此 ContentType?
虽然 ContentType 对象是只读的,但 MediaSubtype 属性 不是。
所以使用以下内容,我可以添加我们需要的 x- 前缀。
var part = SourceEmail.BodyParts.First(x => x.ContentType.MediaSubtype == "pkcs7-signature");
part.ContentType.MediaSubtype = "x-pkcs7-signature";
我还更新了邮件的整体内容类型。
var header = SourceEmail.Body.ContentType.Parameters.FirstOrDefault(x => x.Name == "protocol" && x.Value == "application/pkcs7-signature");
header.Value = "application/x-pkcs7-signature";
为清楚起见省略了错误检查。