Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Email w/ Embedded Image

Status
Not open for further replies.

trbyrne

IS-IT--Management
Jul 5, 2007
60
US
I am trying to send an Email with an embedded image in vb.net 2005. The email is sent but the image appears as a broken link. The code I am using is below:

'create the mail message
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("me@mycompany.com")
mail.To.Add("rbyrne@brombergs.com")
mail.To.Add("rbyrne1@charter.net")

'set the content
mail.Subject = "This is an email"

Dim A As System.Net.Mail.Attachment = New System.Net.Mail.Attachment("c:\anniversary.jpg")
Dim RGen As Random = New Random()
A.ContentId = RGen.Next(100000, 9999999).ToString()
mail.Body = "Here is the image --> <img src=""cid:" + A.ContentId + """>"
mail.IsBodyHtml = True

'send the message
Dim smtp As New SmtpClient(mailserver.Text) 'specify the mail server address
smtp.Send(mail)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top