G
Guest
Hi!
Inline attachments (images) doesn't seem to work. I have a html-document
that I know works fine. This works fine in another mailing-product for me.
Not sure if to use attachment with dispositiontype inline or like in these
snippet, alternativeview and linkedresource? Can anyone see whats wrong?
Here are a snippet from my html-page:
body { background-image: url(cid:back.gif); background-repeat: repeat-y;
background-attachment: fixed}
Here are a snippet from my mailing-code:
Dim l_Message As New MailMessage()
l_Message.Subject = l_strSubject
l_Message.From = New MailAddress(m_strFrom)
Dim l_RecipientsTo As MailAddressCollection = l_Message.To
Dim l_RecipientsCc As MailAddressCollection = l_Message.CC
If m_strSendTo.Length > 0 Then
For Each l_strAddressToItem As String In
m_strSendTo.TrimEnd().Split(";".ToCharArray())
l_RecipientsTo.Add(New
MailAddress(l_strAddressToItem))
Next
End If
If m_strCcTo.Length > 0 Then
For Each l_strAddressCcItem As String In
m_strCcTo.TrimEnd().Split(";".ToCharArray())
l_RecipientsCc.Add(New
MailAddress(l_strAddressCcItem))
Next
End If
l_Message.IsBodyHtml = True
l_Message.Priority = MailPriority.High
Dim avhtml As AlternateView =
AlternateView.CreateAlternateViewFromString(l_strHTMLBodyText)
avhtml.ContentType.MediaType = "text/html"
avhtml.TransferEncoding =
System.Net.Mime.TransferEncoding.QuotedPrintable
avhtml.ContentType.MediaType = "text/html"
Dim lr As LinkedResource = New
LinkedResource(m_strSMTPAttachment) 'ms, "image/gif")
lr.ContentType.MediaType =
System.Net.Mime.MediaTypeNames.Image.Gif
lr.TransferEncoding = Net.Mime.TransferEncoding.Base64
lr.ContentId = "back.gif"
lr.ContentType.Name = "back.gif"
lr.ContentLink = New Uri("cid:back.gif")
avhtml.LinkedResources.Add(lr)
l_Message.AlternateViews.Add(avhtml)
If l_strPlainTextBody.Length > 0 Then
Dim avtext As AlternateView =
AlternateView.CreateAlternateViewFromString(l_strPlainTextBody)
avtext.ContentType = New ContentType("text/plain")
avtext.ContentType.MediaType = "text/plain"
avtext.TransferEncoding = TransferEncoding.QuotedPrintable
l_Message.AlternateViews.Add(avtext)
End If
m_MailClient = New SmtpClient(m_strSMTPHost,
m_intSMTPHostPort)
m_MailClient.Credentials =
System.Net.CredentialCache.DefaultCredentials
m_MailClient.EnableSsl = False
m_MailClient.Timeout = 100000
m_MailClient.DeliveryMethod = SmtpDeliveryMethod.Network
m_MailClient.Send(l_Message)
Inline attachments (images) doesn't seem to work. I have a html-document
that I know works fine. This works fine in another mailing-product for me.
Not sure if to use attachment with dispositiontype inline or like in these
snippet, alternativeview and linkedresource? Can anyone see whats wrong?
Here are a snippet from my html-page:
body { background-image: url(cid:back.gif); background-repeat: repeat-y;
background-attachment: fixed}
Here are a snippet from my mailing-code:
Dim l_Message As New MailMessage()
l_Message.Subject = l_strSubject
l_Message.From = New MailAddress(m_strFrom)
Dim l_RecipientsTo As MailAddressCollection = l_Message.To
Dim l_RecipientsCc As MailAddressCollection = l_Message.CC
If m_strSendTo.Length > 0 Then
For Each l_strAddressToItem As String In
m_strSendTo.TrimEnd().Split(";".ToCharArray())
l_RecipientsTo.Add(New
MailAddress(l_strAddressToItem))
Next
End If
If m_strCcTo.Length > 0 Then
For Each l_strAddressCcItem As String In
m_strCcTo.TrimEnd().Split(";".ToCharArray())
l_RecipientsCc.Add(New
MailAddress(l_strAddressCcItem))
Next
End If
l_Message.IsBodyHtml = True
l_Message.Priority = MailPriority.High
Dim avhtml As AlternateView =
AlternateView.CreateAlternateViewFromString(l_strHTMLBodyText)
avhtml.ContentType.MediaType = "text/html"
avhtml.TransferEncoding =
System.Net.Mime.TransferEncoding.QuotedPrintable
avhtml.ContentType.MediaType = "text/html"
Dim lr As LinkedResource = New
LinkedResource(m_strSMTPAttachment) 'ms, "image/gif")
lr.ContentType.MediaType =
System.Net.Mime.MediaTypeNames.Image.Gif
lr.TransferEncoding = Net.Mime.TransferEncoding.Base64
lr.ContentId = "back.gif"
lr.ContentType.Name = "back.gif"
lr.ContentLink = New Uri("cid:back.gif")
avhtml.LinkedResources.Add(lr)
l_Message.AlternateViews.Add(avhtml)
If l_strPlainTextBody.Length > 0 Then
Dim avtext As AlternateView =
AlternateView.CreateAlternateViewFromString(l_strPlainTextBody)
avtext.ContentType = New ContentType("text/plain")
avtext.ContentType.MediaType = "text/plain"
avtext.TransferEncoding = TransferEncoding.QuotedPrintable
l_Message.AlternateViews.Add(avtext)
End If
m_MailClient = New SmtpClient(m_strSMTPHost,
m_intSMTPHostPort)
m_MailClient.Credentials =
System.Net.CredentialCache.DefaultCredentials
m_MailClient.EnableSsl = False
m_MailClient.Timeout = 100000
m_MailClient.DeliveryMethod = SmtpDeliveryMethod.Network
m_MailClient.Send(l_Message)