0 votes

I send an email containing only a hyperlink, e.g. Google.

When the email is imported using Imap (VB code shown below), the Body of the email contains Google, as Plain Text, followed by a URL in square brackets, i.e. [http://www.google.com/]. Clicking on the Plain Text obviously does nothing. Clicking on the URL works, but it's not what we want.

What we do want is for the Body of the email to be exactly as it was sent, i.e. just a hyperlink, Google, which still works, i.e. when you click it, you are directed to the Google website. We don't want to see the URL [http://www.google.com/] at all.

Please can you help ?

Thank you.

Actual VB code follows:

Using imap As New Imap
    imap.ConnectSSL(strIMAPConnection)
    imap.UseBestLogin(strMailboxName, strPassword)
    imap.SelectInbox()
    Dim uids As List(Of Long) = imap.Search(Flag.Unseen)
    For Each uid As Long In uids
        Dim eml = imap.GetMessageByUID(uid)
        Dim email As IMail = New MailBuilder() _
        .CreateFromEml(eml)
        '
        If email.IsHtml Then 
            Email_Body = email.GetBodyAsText
        ElseIf email.IsRtf Then
            Email_Body = email.Rtf
        ElseIf email.IsText Then
            Email_Body = email.Text
        End If
        '
    Next
    imap.Close()
End Using
by

1 Answer

0 votes

You are using plain text email version, and you should be using HTML.

This line in particular doesn't make much sense:

If email.IsHtml Then 
    Email_Body = email.GetBodyAsText

If you get HTML email use email.Html (IMail.Html), no point in getting plain text or converting html to plain text with IMail.GetBodyAsText method.

From Mail.dll documentation:

GetBodyAsText - returns body in plain text format. Uses IMail.Text, IMail.GetTextFromHtml() or IMail.GetTextFromRtf().

by (297k points)
...