显式填充ContentDisposition字段可以达到目的。
if (attachmentFilename != null){ Attachment attachment = new Attachment(attachmentFilename, MediaTypeNames.Application.Octet); ContentDisposition disposition = attachment.ContentDisposition; disposition.CreationDate = File.GetCreationTime(attachmentFilename); disposition.ModificationDate = File.GetLastWriteTime(attachmentFilename); disposition.ReadDate = File.GetLastAccessTime(attachmentFilename); disposition.FileName = Path.GetFileName(attachmentFilename); disposition.Size = new FileInfo(attachmentFilename).Length; disposition.DispositionType = DispositionTypeNames.Attachment; message.Attachments.Add(attachment); }
顺便说一句 ,在使用Gmail的情况下,您可能对ssl安全甚至端口有一些例外!
smtpClient.EnableSsl = true;smtpClient.Port = 587;
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)