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


VB
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 
Posted

VB
Imports System.Net.Mail
Imports System.Net.Mime
   
   
Comments
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