我有一個.Net 4.5應用程序發送電子郵件,附件。在電子郵件在桌面上打開時,它會按預期工作,但在移動設備上打開時(本例中爲iPhone),附件將顯示爲內嵌HTML,而不是附件。Asp.Net電子郵件附件在手機上顯示內嵌(iPhone)
但是,當我將同一封電子郵件從我的桌面轉發到手機時,附件在我的手機上正確顯示,所以我幾乎可以確定它與我如何指定MIME或內容類型,配置等有關。但我看不到我做錯了什麼。
這裏是代碼 - 注意
att.ContentType = new System.Net.Mime.ContentType("multipart/mixed");
並創造在iPhone上的附件,但它是類型= MIME-附件不會打開。
我難倒&客戶端等待 - 任何幫助非常感謝!
private void SendNotice(string body, string attachment, string email, bool pdf = false)
{
MailMessage message = new MailMessage();
message.From = new MailAddress(ConfigurationManager.AppSettings["SMTP.SendFrom"]);
message.Subject = ConfigurationManager.AppSettings["MatchedNoticeSubject"];
message.To.Add(new MailAddress(email));
message.ReplyToList.Add(new MailAddress(ConfigurationManager.AppSettings["SMTP.ReplyTo"]));
message.Body = body;
message.IsBodyHtml = true;
Attachment att = Attachment.CreateAttachmentFromString(attachment, "SeniorInfo.html", System.Text.Encoding.ASCII, "text/html");
//specifying this creates an attachment of type "mime-attachment" that does not open
//att.ContentType = new System.Net.Mime.ContentType("multipart/mixed");
message.Attachments.Add(att);
SmtpClient server = new SmtpClient()
{
EnableSsl = (ConfigurationManager.AppSettings["SMTP.EnableSSL"].ToLower() == "true"),
Host = ConfigurationManager.AppSettings["SMTP.Server"],
Port = Convert.ToInt16(ConfigurationManager.AppSettings["SMTP.Port"]),
Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["SMTP.Account"], ConfigurationManager.AppSettings["SMTP.Password"])
};
server.Send(message);
}