次のコードを使用して、MailMessageにイメージを埋め込みます。私がしようとしているのは、電子メールにドキュメント(pdfまたはdocx)を埋め込むことです。MailMessageのLinkedResourcesを使用したドキュメントの埋め込み
href = "cdi:myDoc.pdf"へのリンクを使ってハイパーリンクを試しましたが、それは動作しません。私もMailMessage.Attachments.Add()を使ってみましたが、メッセージを文書に埋め込むのではなく、添付ファイルセクションに文書を追加しました。
誰でもメールメッセージにドキュメントを埋め込む方法を教えてください。私は、Outlookがメッセージの本文に添付ファイルを配置することができますが、私はmailMessageでそれを行う方法を理解することはできません知っています。
おかげスーザン
Sub MultiPartMime()
Dim mail As New MailMessage()
mail.From = New MailAddress("[email protected]")
mail.To.Add("[email protected]")
mail.Subject = "This is an email"
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString("<b>this is bold text, and viewable by <img src=""cdi:companylogo""> those mail clients that support html</b>", Nothing, "text/html")
LinkedResource logo = new LinkedResource("c:\temp\logo.gif")
logo.ContentId = "companylogo"
htmlView.LinkedResources.Add(logo)
mail.AlternateViews.Add(htmlView)
'send the message
Dim smtp As New SmtpClient("127.0.0.1") 'specify the mail server address
smtp.Send(mail)
End Sub 'MultiPartMime