当前位置:编程学习 > C#/ASP.NET >>

发送带附件邮件成功,我用新浪测试成功为什么下载附件以后,打开里边什么都没有啊???

核心代码
难道是新浪的问题?大家帮我看看

 public bool SendMail(MailInfo mailinfo)
        {
          
            string[] mailTos = mailinfo.MMailTo;
            string[] mailCcs = mailinfo.MMailCc;
            string[] mailBccs = mailinfo.MMailBcc;
            string[] attachments = {"E:\\data.doc"};
            
                        bool isSend = false;

            MailMessage Email = new MailMessage();
            Email.Subject = mailinfo.MMailSubject;
            Email.Body = mailinfo.MMailBody;
            MailAddress MailFrom = new MailAddress(mailinfo.MMailFrom);
            Email.From = MailFrom;

            //向集合中添加收件人地址
            if (mailTos != null)
            {
                foreach (string to in mailTos)
                {
                    if (!string.IsNullOrEmpty(to))
                    {
                        Email.To.Add(to);
                    }
                }
            }

            //向集合中添加抄送地址
            if (mailCcs != null)
            {
                foreach (string cc in mailCcs)
                {
                    if (!string.IsNullOrEmpty(cc))
                    {
                        Email.CC.Add(cc);
                    }
                }
            }

            //向集合中添加密送地址
            if (mailBccs != null)
            {
                foreach (string bcc in mailBccs)
                {
                    if (!string.IsNullOrEmpty(bcc))
                    {
                        Email.Bcc.Add(bcc);
                    }
                }
            }

            //添加附件集合
            if (attachments != null)
            {
                foreach (string att in attachments)
                {
                    if (!string.IsNullOrEmpty(att))
                    {
                       
            Attachment AttachmentObject = new Attachment(att);
                        
                        Email.Attachments.Add(AttachmentObject);

                    }
                }
            }
            
            

            try
            {
                
                SmtpClient Client = new SmtpClient(this.mSMTPServer, this.mSMTPPort);
                Client.UseDefaultCredentials = false;
                Client.Credentials = new NetworkCredential(this.mSMTPUserName, this.mSMTPpass);
                Client.DeliveryMethod = SmtpDeliveryMethod.Network;
                Email.BodyEncoding = Encoding.Default;
                //Email.IsBodyHtml = true;

                Client.Send(Email);
                //AttachmentObject.Dispose();
               
                isSend = true;
            }
            catch (Exception ex)
            {
                throw ex;

            }

            return isSend;
        }
        #endregion
    }
}
补充:.NET技术 ,  ASP.NET
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,