C#发送带附件的邮件,为什么附件成了bin后缀的文件?

WX 发布于 2013/07/23 22:59
阅读 1K+
收藏 0

不知道哪位大神有遇到过这类问题,我原本是rar的附件发送出去之后变成了20001.bin的附件,下载下来也不能解压。这到底是肿么回事啊。。

以下是部分关键代码:

 

                _mailMessage = new MailMessage();
                _mailMessage.To.Clear();
                ToMails.ForEach(toMail => _mailMessage.To.Add(toMail));

                _mailMessage.From = new MailAddress(FromMail, DisplayName);
                _mailMessage.Subject = Subject;
                _mailMessage.SubjectEncoding = Encoding.UTF8;
                _mailMessage.Body = Body;
                _mailMessage.BodyEncoding = Encoding.UTF8;
                _mailMessage.Attachments.Clear();
                AttachedFiles.ForEach(file => _mailMessage.Attachments.Add(new Attachment(file.FullName, MediaTypeNames.Application.Zip) { Name = file.Name, }));//MediaTypeNames.Application.Octet

                _smtpClient = new SmtpClient()
                {
                    Host = SmtpHost,
                    Port = SmtpPort,
                    Timeout = SmtpTimeOut,
                    Credentials = new NetworkCredential(FromMail, FromMailPassword),
                };
                _smtpClient.SendCompleted += new SendCompletedEventHandler(SendCompletedCallback);

                SendResultInfo.AsyncSendResult = AsyncSendResult.Success;

 

加载中
返回顶部
顶部