Hi

I am not familiar in how to create HTML Embeded emeil.
Currently I am using below code, It is work fine and send email
with plain text. It is not look nice. I need to formated embeded
email with logo and below information together to the email. I have
tried in Google. But could not find proper solution. I am also getting confusion

Pls advice me.

Thank you in advance

Maideen

Below is code ( currently I am using , it is fine)

Private Sub SendEmail(EmailAddress As String)

        Dim mail As New MailMessage()
        mail.To.Add(EmailAddress)
        mail.From = New MailAddress("xxxxxx@xxx.com")
        mail.CC.Add(Me.txtSAgentEmail.Text)
        mail.Subject = "Complaint"
        mail.Body = "Thank you for your suggession " & "<br>"
        mail.Body = mail.Body & " Date:- " & Date & "<br>"
        mail.Body = mail.Body & " Case ID:- " & caseid & "<br>"
        mail.Body = mail.Body & " Pakcage:- " & txtPKCode & "<br>"
        mail.Body = mail.Body & " Subscriber ID:- " & Code & "<br>"
        mail.Body = mail.Body & " Subscriber Name:- " & Name & "<br>"
        mail.Body = mail.Body & " Company:- " & Company & "<br>"
        mail.Body = mail.Body & " Job Title:- " & JobTitle & "<br>"
        mail.Body = mail.Body & " Address:- " & Address1 & "<br>"
        mail.Body = mail.Body & " Address:- " &BAddress2 & "<br>"
        mail.Body = mail.Body & " Post Code:- " & PosCode & "<br>"
        mail.Body = mail.Body & " City:- " & City & "<br>"
        mail.Body = mail.Body & " State:- " & State & "<br>"
        mail.Body = mail.Body & " Country:- " & Country & "<br>"
        mail.Body = mail.Body & " Tel:- " & TelNo & "<br>"
        mail.Body = mail.Body & " HP:- " & HPNo & "<br>"
        mail.Body = mail.Body & " Compalints:- " & Me.txtComplaints.Text & "<br>"
        mail.Body = mail.Body & " Status:- " & Status & "<br>"

        mail.IsBodyHtml = True

        Dim smtp As New SmtpClient()
        smtp.Host = "smtp.xxxx.com"
        smtp.EnableSsl = True
        Dim NetworkCred As New System.Net.NetworkCredential()
        NetworkCred.UserName = mail.From.Address
        NetworkCred.Password = "password"
        smtp.UseDefaultCredentials = False
        smtp.Credentials = NetworkCred
        smtp.Port = 587
        smtp.Send(mail)


    End Sub

Hi

Your code is sending HTML email and you have the IsBodyHtml property properly set so I am not sure why you think it is plain text. What I have noticed is that other than the inclusion of <br> tags, you are not using any other HTML markup which might be why you think it is plain text.

As a test, add some markup to your text, for example, change your first line to mail.Body = "<b>Thank you for your suggession</b> " & "<br />" and test it. You should then see that the email has the first line in bold.

Some other comments, your <br> tags should be <br /> (i.e. they are self closing).

Also, I would recommend using a StringBuilder to build your message, especially if the content of your email is going to be quite large as this has performance benefits.

HTH

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.