Click here to Skip to main content
15,068,678 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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()
'////////////////////////// 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
        ii = i
    End If
    Dim attachment As New MailAttachment(Server.MapPath("~\smp\image_" & ii & ".jpg"))
MyMail.BodyEncoding = Encoding.UTF8
MyMail.BodyFormat = MailFormat.Html
MyMail.Priority = MailPriority.High

MyMail.Fields.Add("", "1") 'basic authentication
MyMail.Fields.Add("", "xxx") 'set your username here
MyMail.Fields.Add("", "xxx") 'set your password here
SmtpMail.SmtpServer = "xxx" 'your real server goes here
end function 

Imports System.Net.Mail
Imports System.Net.Mime
Member 8062393 1-Mar-12 4:30am
I'm Using "System.Web.Mail" and "VB"
Check this Tip/Trick
How to embed an image in email body[^]

For code conversion(C# to VB.NET & etc.,) check this blog post .NET Code Conversion - Convert your code[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900