Outlook附件没有显示也没有下载,完全在gmail上工作是截图
以下是我的代码,尝试使用fielstream并直接附加包含内容类型的文件但可能缺少其他内容
> MailMessage msg = new MailMessage();
> msg.From = new MailAddress("info@onyxgroup.com.pk");
>
> msg.To.Add(email);
>
> msg.IsBodyHtml = false;
> msg.Body = "hah";
>
> var inlinepdf = new LinkedResource(Server.MapPath("~/Invoices/Invoice.pdf"));
> inlinepdf.ContentId = Guid.NewGuid().ToString();
>
>
> var inlineLogo = new LinkedResource(Server.MapPath("~/images/logo-default.png"));
> inlineLogo.ContentId = Guid.NewGuid().ToString();
>
> string body = string.Format(@"
> <p>Onyx International</p>
> <img src=""cid:{0}"" width=""100px""/>
> <p>www.onyxgroup.com.pk</p>", inlineLogo.ContentId);
>
> var view = AlternateView.CreateAlternateViewFromString(body, null, "text/html");
> view.LinkedResources.Add(inlineLogo);
> msg.AlternateViews.Add(view);
>
> string attachmentPath = Server.MapPath("~/Invoices/Invoice.pdf");
> FileStream fs = new FileStream(attachmentPath, FileMode.Open, FileAccess.Read);
>
>
> Attachment a = new Attachment(fs, "Invoice.pdf", MediaTypeNames.Application.Pdf);
> msg.Attachments.Add(a);
>
> msg.Subject = "Invoice | Onyx International";
> SmtpClient smtp = new SmtpClient();
> smtp.Host = "smtp.gmail.com";
> smtp.Port = 587;
> smtp.EnableSsl = true;
> smtp.Credentials = new System.Net.NetworkCredential("ahsan.sykov@gmail.com",
> "password");
> smtp.Send(msg);
答案 0 :(得分:0)
不知道为什么但它在hotmail / outlook中运行良好,但没有使用新的outlook / live版本。