'----------------------------------------------
'Prepare the message text.
'----------------------------------------------
Dim m_MessageBody As String = ""
m_MessageBody = "This is a test image"
'Put the message text into an AlternateView.
Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(m_MessageBody, Nothing, "text/plain")
'Get a unique ID for the image.
Dim strImageID As String = Now.Ticks
System.Threading.Thread.Sleep(20)
'---------------------------------------------
'Prepare the HTML.
'----------------------------------------------
Dim htmlBody As String = ""
'Put the message into the html body.
htmlBody += m_MessageBody
'Leave a blank line.
htmlBody += "<br/>"
'Put the image tag in.
htmlBody += "<img alt="""" hspace=0 src=""cid:" & strImageID & """ align=baseline border = 0 >"
'Put the html body into an Alternate View.
Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(htmlBody, Nothing, "text/html")
'-----------------------------------------------
'Prepare the Image
'-----------------------------------------------
Dim MyImage As AlternateView
'Put the image into an Alternate view.
MyImage= New AlternateView(Server.MapPath("~\Graphics\MyImage.jpg"), MediaTypeNames.Image.Gif)
MyImage.ContentId = strImageID
MyImage.TransferEncoding = TransferEncoding.Base64
'Put the image into a Linked resource.
Dim MyImageLinkedResource As LinkedResource = New LinkedResource(Server.MapPath("~\Graphics\MyImage.jpg"), MediaTypeNames.Image.Gif)
MyImageLinkedResource .ContentId = strImageID
'Add this resource to the HTML view.
htmlView.LinkedResources.Add(MyImageLinkedResource )
'Add the all the Alternate Views to the Message.
msg.AlternateViews.Add(MyImage)
msg.AlternateViews.Add(plainView)
msg.AlternateViews.Add(htmlView)
'Set the message Body to HTML.
msg.IsBodyHtml = True
[/code}