110,571
社区成员
发帖
与我相关
我的任务
分享
string name = "这里是附件名称";
MIME_Entity entity = MIME_Entity.CreateEntity_Attachment(name, new MemoryStream("这里是附件数据"));
string encodingStr = "utf-8".ToUpper();
Encoding encoding = Encoding.GetEncoding(encodingStr);
if (encoding.GetByteCount(name) > name.Length) {
byte[] barray = encoding.GetBytes(name);
string newName = "=?" + encodingStr + "?B?" + Convert.ToBase64String(barray) + "?=";
string format = "Content-Disposition: attachment;\r\n\tfilename=\"{0}\";\r\n\tsize=\"{1}\"\r\n";
string formatValue = string.Format(format, newName, entity.ContentDisposition.Param_Size);
entity.ContentDisposition = MIME_h_ContentDisposition.Parse(formatValue);
}
multipartMixed.BodyParts.Add(entity); //MIME_b_MultipartMixed multipartMixed