HTML Email VB.NET

Soldato
Joined
20 Jan 2005
Posts
2,722
Location
Whitley Bay
Hi there,

I've written a form on my application which sends a plain text email.
Problem is, I now need to make it an HTML email as the 'signature' element needs to be bold.

Every time I've tried in the past it's either included my code in the final email or just bombed out completely.

I'm hoping someone can take a look at my code and tell me how to include some formatting.

Code:
 Private Sub Send_button_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles Send_button.LinkClicked

        'CREATE NEW OUTLOOK APPLICATION
        Dim oApp As Outlook._Application
        oApp = New Outlook.Application()

        'CREATE NEW OUTLOOK MESSAGE
        Dim oMsg As Outlook._MailItem
        oMsg = oApp.CreateItem(Outlook.OlItemType.olMailItem)
        oMsg.BodyFormat = Outlook.OlBodyFormat.olFormatHTML

        'CHECK WHICH ARTICLE HAS BEEN SELECTED FOR SENDING
        For i As Integer = 0 To ArticleIDs.Items.Count - 1
            ArticleIDs.SetSelected(i, True)
        Next
        For i As Integer = 0 To ArticleTitles.Items.Count - 1
            ArticleTitles.SetSelected(i, True)
        Next
        For i As Integer = 0 To ArticleSource.Items.Count - 1
            ArticleSource.SetSelected(i, True)
        Next

        Dim URLBODY As String
        If ArticleSource.SelectedItem.ToString = "US KB" Then
            URLBODY = (":" + Chr(13) + "http://URL" + _
                     Chr(13) + Chr(13) + "Enter the number " + ArticleIDs.SelectedItem.ToString + " in 'Search Text' and choose Answer ID in 'Search By' for the article:" + Chr(13) + _
                     ArticleTitles.SelectedItem.ToString)
        Else
            URLBODY = (" article: " + ArticleTitles.SelectedItem.ToString + Chr(13) + "http://differentURL=" + ArticleIDs.SelectedItem.ToString)
        End If

        'SET THE 'FROM', 'TO', 'SUBJECT', AND 'BODY' OF THE EMAIL
        oMsg.SentOnBehalfOfName = "[email protected]"
        oMsg.To = Recipient.Text
        oMsg.Subject = ("Support Issue, Account Number: " + Account.Text + ", Incident Reference Number: " + Incident.Text)
        oMsg.Body = ("Dear " + CustName.Text + "," + Chr(13) + Chr(13) + "Thank you for your " + QueryType + " query of " + DateTime.Today.ToString("dddd, dd MMMM yyyy") + "." + Chr(13) + Chr(13) + _
                     "Please refer to the link below for our knowledgebase" + URLBODY + Chr(13) + Chr(13) + "If you have any further queries please contact the Technical Support team on (phone number)." + Chr(13) + Chr(13) + _
                     "Assuring you of our best attention at all times." + Chr(13) + Chr(13) + "Kind Regards" + Chr(13) + Chr(13) + _
                     LoggedOnUser + Chr(13) + "Technical Support" + Chr(13) + "Company Name Ltd" + Chr(13) + "Mailto:[email protected]" + Chr(13) + "http://url" + Chr(13) + _
                     "marketing blurb" + _
                     "more marketing blurb")

        'SEND THE EMAIL
        oMsg.Send()

The area below within the oMsg.Body needs to be in bold:
Code:
"Technical Support" + Chr(13) + "Company Name Ltd" + Chr(13) + "Mailto:[email protected]" + Chr(13) + "http://url" + Chr(13) + _
                     "marketing blurb" + _
                     "more marketing blurb"

Thanks in advance and apologies that my code is scrappy.

Si
:)
 
Back
Top Bottom