Adapt the code succinctly described in this answer: https://stackoverflow.com/a/11000938
This appears to be the right approach. Articles describing this in more detail include these:
Frage
Is there a way to set the ContentDisposition
of a LinkedResource
to be inline
, ie in the case of an image?
Here's how I am building my LinkedResource
right now:
Dim img As LinkedResource = New LinkedResource(filePath)
Dim fileType As String = ""
Dim attName As String = "image" + fileName + "." + fileExt
If (fileExt = "jpg" Or fileExt = "jpeg") Then
img.ContentType.MediaType = System.Net.Mime.MediaTypeNames.Image.Jpeg
ElseIf (fileExt = "gif") Then
img.ContentType.MediaType = System.Net.Mime.MediaTypeNames.Image.Gif
ElseIf (fileExt = "png") Then
img.ContentType.MediaType = "image/png"
End If
img.ContentId = attName
img.ContentType.Name = attName
linkedResources.Add(img)
Lösung
Adapt the code succinctly described in this answer: https://stackoverflow.com/a/11000938
This appears to be the right approach. Articles describing this in more detail include these:
Andere Tipps
LinkedResources
already sets the ContentDisposition
to inline
.
In fact, LinkedResources
appears to exist only for the purpose of adding hidden embedded images and other inline
content to your AlternateView
. There is no option to set a filename, since users will never see it.
Use Attachments
when you want visible, user-accessible files attached to your email, with filenames.
Use LinkedResources
when you want hidden resources such as embedded images in your email, which you then reference in HTML with cid:.