• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 213
  • Last Modified:

Programatically create formatted / rich text to send in an email

I need  to send formatted text (bullet points, bolded words etc...)  in an email from our app.  I must also fill in some of the information from the database.   Such as names, order details etc..  

The code snippet details how I am sending the email which works.

How can I send this in the body of the email with all the formatting they requested?

Thanks!


 


 

Dim StringCommand As New System.Text.StringBuilder
 
        StringCommand.Append("mailto:")
        StringCommand.Append(Recipient)
        StringCommand.Append("?")
 
        If Subject <> "" Then
            StringCommand.Append("subject=" & Subject & "&")
        End If
 
        If CC <> "" Then
            StringCommand.Append("cc=" & CC & "&")
        End If
 
        If BCC <> "" Then
            StringCommand.Append("bcc=" & BCC & "&")
        End If
 
 
        If Body <> "" Then
            StringCommand.Append("body=" & Body & "&")
        End If
 
   
        System.Diagnostics.Process.Start(StringCommand.ToString)

Open in new window

0
KimberleyY
Asked:
KimberleyY
  • 2
1 Solution
 
Jason EvansSenior Software DeveloperCommented:
Hi KimberleyY.

You should look at using objects in the System.Net.Mail namespace in order to get HTML sent. Have a look at the example code.

Hope this helps.
Jas.
Imports System.Net.Mail 
Public Class MyEmail 
    Public Sub SendEmail()
        Dim msg As New MailMessage
        Dim smtpServer As New SmtpClient 
        smtpServer.Port = 25
        smtpServer.Host = "nameofemailserver"
        smtpServer.Credentials = New Net.NetworkCredential("username", "password") 
        msg.Body = "<h1>Test</h1>"
        msg.IsBodyHtml = True 
        smtpServer.Send(msg)
    End Sub
End Class

Open in new window

0
 
KimberleyYAuthor Commented:
Hi MrClyfar,

Thanks!  I was afradi that the message needed to be in HTML.  I did find some free converters for rtf to html.  And I will also look into the System.Net.Mail namespace.

Thanks Again
0
 
KimberleyYAuthor Commented:
Good Job
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now