将图像嵌入电子邮件 [英] Embed image in Email

查看:149
本文介绍了将图像嵌入电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在电子邮件中有此代码用于嵌入图像,在Outlook中可正常使用,但在gmail或ymail中无法使用...
请帮忙


I have this Code For Embed image in email, Work correctly in outlook but not worked in gmail or ymail ...
Please help


Imports System.Web.Mail
Imports System.IO
Imports System.IO.Directory

function snd_mail()
Dim bdm As String
'/////////////////////////////// READ */* HTML */*
Dim objStreamReader As StreamReader = File.OpenText(Server.MapPath("~\smp\index.html"))
bdm = objStreamReader.ReadToEnd()
objStreamReader.Close()
'////////////////////////// END READ */* HTML */*
bdm = Replace(bdm, "src='", "src='cid:")

Dim MyMail As MailMessage = New MailMessage()
MyMail.From = "xxx"
MyMail.To = "xxx"
MyMail.Subject = "xxx"
MyMail.Body = bdm
For i = 1 To 53
    Dim ii As String
    If i < 10 Then
        ii = "0" & i
    Else
        ii = i
    End If
    Dim attachment As New MailAttachment(Server.MapPath("~\smp\image_" & ii & ".jpg"))
    MyMail.Attachments.Add(attachment)
Next
MyMail.BodyEncoding = Encoding.UTF8
MyMail.BodyFormat = MailFormat.Html
MyMail.Priority = MailPriority.High

MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1") 'basic authentication
MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "xxx") 'set your username here
MyMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxx") 'set your password here
SmtpMail.SmtpServer = "xxx" 'your real server goes here
SmtpMail.Send(MyMail)
end function 

推荐答案

Imports System.Net.Mail
Imports System.Net.Mime




以下链接可能对您有帮助:

使用ASP.NET嵌入电子邮件中的图像 [ ^ ]

http://www.asp.net/web-forms/videos/how-do-i/how-do-i-embed-an-image-in-an-email-with-aspnet [通过ASP.NET发送带有嵌入式图像的电子邮件 [ ^ ]
Hi,

Following links may be helpful for you:

Embed an Image in Email using ASP.NET[^]

http://www.asp.net/web-forms/videos/how-do-i/how-do-i-embed-an-image-in-an-email-with-aspnet[^]

Sending email with an embedded image through ASP.NET[^]



这篇关于将图像嵌入电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆