此代码适用于绝对每个邮件客户端,除了Mail for OSX,它只是插入一个标题为“Mail Attachment(2.6kb)”的纯灰色图标
任何人都可以看到可能缺少的内容,使其在所有邮件客户端中都能正常工作。??
Dim mail As New MailMessage()
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("tom@myaddress.com")
mail.Subject = "This is an email"
mail.IsBodyHtml = True
mail.Priority = MailPriority.Normal
Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString("This is my plain text content, viewable by those clients that don't support html", Nothing, "text/plain")
Dim logo As New LinkedResource(Server.MapPath("images1/links/beach-icon.jpg"))
logo.ContentId = "embeddedimage"
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString("<p>Here is an embedded image.</p> <p><img alt='' hspace='0' src='cid:embeddedimage' align='baseline' border='0' ></p> <p>It's pretty awesome</p>", Nothing, "text/html")
htmlView.LinkedResources.Add(logo)
mail.AlternateViews.Add(plainView)
mail.AlternateViews.Add(htmlView)
Dim smtp As New SmtpClient("localhost") 'specify the mail server address
smtp.Send(mail)
答案 0 :(得分:3)
Dim logo As New LinkedResource(Server.MapPath("images1/links/beach-icon.jpg"), "image/jpeg")