发送带有嵌入HTML图像的电子邮件 [英] Sending Email With Embaded HTML Image

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

问题描述

请有人帮助我.我正在为生日祝福写一封提醒邮件
代码是:

Please Some one help me. I am writing an alert mail for birthday wishesh
The code is :

Imports System.Data
Imports System.Data.OleDb
Imports System.Web
Imports System.Text
Imports System.Diagnostics.Process
Imports System.Net.Mail
Imports System.Net

Imports System.Net.Mime


Module Module1

    Sub Main()
   
       



     
        Dim strBody As String
        Dim MyMail As MailMessage = New MailMessage()

        'first we create the Plain Text part
        Dim palinBody As String = "This is my plain text content, viewable by those clients that don't support html"
        Dim plainView As AlternateView = AlternateView.CreateAlternateViewFromString(palinBody, Nothing, "text/plain")



        strBody = "<HTML><BODY><TABLE  ID = 'tblMain' border ='0' width ='100%'>"
        strBody = strBody + "<TR>"
        strBody = strBody + "<TD  width ='40%' colspan ='4'><img border='0'src=""cid:uniqueId""alt ='BirthDayImage'width ='293' height ='327'/></TD>"
        ' strBody = strBody + "<TD  width ='40%' colspan ='4'><img border='0'src ='strImgSource'    alt ='BirthDayImage'width ='293' height ='250'/></TD>"

        strBody = strBody + " <TD width ='60%' colspan ='6'>"

        strBody = strBody + "<table>"
        strBody = strBody + "<tr>"
        strBody = strBody + "<td width ='70%' valign ='top'colspan ='7' >"
        strBody = strBody + " <p>"
        strBody = strBody + " <b> <font size='7' color=navy face='Monotype Corsiva'>"
        strBody = strBody + "<span style='font-size:30.0pt;line-height:150%;font-family:'Monotype Corsiva';color:navy;font-weight:bold'>Mr.Amit Mujumdar </span>"
        strBody = strBody + "</font></b>"
        strBody = strBody + " </p> "
        strBody = strBody + "</td>"
        strBody = strBody + "<td width ='30%'colspan ='3' > "
        strBody = strBody + "<font size='5' color=navy face='Monotype Corsiva'>"
        strBody = strBody + "<span style='font-size:20.0pt;line-height:150%;font-family:'Monotype Corsiva';color:navy;font-weight:bold'>- System</span>"
        strBody = strBody + " </font></b>"
        strBody = strBody + "</td>"
        strBody = strBody + "</tr> "

        strBody = strBody + "<tr>"
        strBody = strBody + "<td width = '100%'colspan ='10'>"
        strBody = strBody + "<p>"
        strBody = strBody + "<b><i> <font size='7' color=navy face='Monotype Corsiva'>"
        ' strBody = strBody + " <span style='font-size:30.0pt;line-height:150%;font-family:'Monotype Corsiva';color:navy;font-weight:bold'>Entire Calyx  family</span>"
        strBody = strBody + " <span style='font-size:30.0pt;line-height:150%;font-family:'Monotype Corsiva';color:navy;font-weight:bold'>Atul Sharma</span>"
        strBody = strBody + " </font></i></b>"
        strBody = strBody + "</p>"
        strBody = strBody + "</td>"
        strBody = strBody + "</tr>"

        strBody = strBody + "<tr>"
        strBody = strBody + "<td width = '100%'colspan ='10'>"
        strBody = strBody + "<p>"
        strBody = strBody + "<b><i><font size='7' color=navy face='Monotype Corsiva'>"
        strBody = strBody + "<span style='font-size:30.0pt;line-height:150%;font-family:'Monotype Corsiva';color:navy;font-weight:bold'>Wishes you a<o:p></o:p></span>"
        strBody = strBody + " </font></i></b>"
        strBody = strBody + "</p>"
        strBody = strBody + "</td>"
        strBody = strBody + "<tr>"

        strBody = strBody + "<tr>"
        strBody = strBody + "<td width = '100%'colspan ='10'>"
        strBody = strBody + "<p>"
        strBody = strBody + " <b><i><font size='7' color=navy face='Monotype Corsiva'> "
        strBody = strBody + " <span style='font-size:30.0pt;font-family:'Monotype Corsiva';color:navy;font-weight:bold;font-style:italic'>Very Happy Birthday!</span>"
        strBody = strBody + "</font></i></b>"
        strBody = strBody + "</p>"
        strBody = strBody + "</td>"
        strBody = strBody + "<tr>"

        strBody = strBody + "<tr>"
        strBody = strBody + "<td width = '100%'colspan ='10'>"
        strBody = strBody + "<p>"
        strBody = strBody + "<b><i><font size='5' color=navy face='Monotype Corsiva'>"
        strBody = strBody + " <span style='font-size:18.0pt;font-family:'Monotype Corsiva';color:navy;font-weight:bold;font-style:italic'>Have a Great Day and Year Ahead!!</span>"
        strBody = strBody + "</font></i></b>"

        strBody = strBody + "</p>"
        strBody = strBody + "</td>"
        strBody = strBody + "<tr>"


        strBody = strBody + " </table>"
        strBody = strBody + " </TD> "

        strBody = strBody + "</TR>"
        strBody = strBody + "</TABLE></BODY></HTML> "

        Dim htmlView As AlternateView = AlternateView.CreateAlternateViewFromString(strBody, Nothing, "text/html")

        'create the AlternateView for embedded image
        Dim imageView As New AlternateView("C:\Documents and Settings\himabindu_rao\My Documents\My Pictures\bd.bmp")
        imageView.ContentId = "uniqueId"


        MyMail.AlternateViews.Add(plainView)

        MyMail.AlternateViews.Add(htmlView)
        MyMail.AlternateViews.Add(imageView)




        MyMail.Subject = "Happy Birthday "
        MyMail.Body = strBody
        'MyMail.To = "systems_applications@calyxindia.com"
        MyMail.To.Add("*****2009@yahoo.in")
        MyMail.From = New MailAddress("****@abcxyz.com")

        Dim smtp As New SmtpClient("MyServerIP")

        smtp.Send(MyMail)




        Console.WriteLine("Mail Sent")








    End Sub

End Module



但是我的图像没有显示在我的邮件正文中.甚至不在Outlook或Yahoo中.
请帮帮我.
谢谢&问候
Atul Sharma
电子邮件:{Removed} @ yahoo.in



But My image is not showing in my mail Body. Even not in Outlook or yahoo.
Please help me.
Thanks & Regards
Atul Sharma
Email:{Removed}@yahoo.in

推荐答案

您没有为保存图像的备用视图设置mime类型.
You didn''t set the mime type for the alternate view that holds the image.


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

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