1
votes

I'm having hard time doing a simple highlight on my text by using HTML in Lotus Notes with VBA.

I had used the following attributes <span style=background:yellow;mso-highlight:yellow> and <style="background-color:yellow"> without any success and I'm almost about to give up. Is it possible to do this simple thing on Lotus Notes or not ?

Attached here are my code and a screenshot of the result :

  1. VBA Code

    Sub SendLocalExtensionEmail()

    Dim nMailBody As String
    Dim nMailSubject As String
    Dim nMailRecipient As Variant
    Dim nMail As Object
    Dim nSession As Object
    Dim nDatabase As Object
    Dim nMime As Object
    Dim nMailStream As Object
    Dim nChild As Object
    Dim nSomeMailBodyText As String
    Dim amountOfRecipients As Integer
    

   msg_var = "<font face=Arial> <p style=font-size:10pt>" & _
          "Dear Sir/ Madam, <br />" & _
          "<br />" & _
          "MANY LINES OF TEXT" & _
          "<font color=red><span style=background:yellow;mso-highlight:yellow>" & _
          "Please revert within 5 working days" & _
          "</font></span>" & _
          "Best Regards, <br />" & _
          "</font>"
    nSomeMailBodyText = msg_var
    nMailRecipient = ""
    nMailSubject = "A great email"

    Set nSession = CreateObject("Notes.NotesSession")
    Set nDatabase = nSession.GetDatabase("", "")
    Call nDatabase.OPENMAIL
    Set nMail = nDatabase.CreateDocument

    nMail.SendTo = "[email protected]"
    nMail.Subject = "[email protected]"

    nSession.ConvertMIME = False
    Set nMime = nMail.CreateMIMEEntity
    Set nMailStream = nSession.CreateStream

    'vBody containung the text in Html
    Call nMailStream.WriteText(nSomeMailBodyText)
    Call nMailStream.WriteText("<br>")

    '-------------------------------------------------------------------

    Set nChild = nMime.CreateChildEntity
    Call nChild.SetContentFromText(nMailStream, "text/html;charset=iso-8859-1", ENC_NONE)
    Call nMailStream.Close
    nSession.ConvertMIME = True
    Call nMail.Save(True, True)
    'Make mail editable by user
    CreateObject("Notes.NotesUIWorkspace").EDITDOCUMENT True, nMail
    'Could send it here
End Sub
  1. And an output of my result:

Output result

Help please ! I'm so curious to know what's happening there.

1
What version(s) of Lotus Notes are you dealing with?Richard Schwartz
Hello @Richard Schwartz, many thanks for your attention. The version of Lotus Notes i'm using is BM Lotus Notes 8.5 (Edition 8.5.2FP4 Révision 20111118.0756-FP4 (Release 8.5.2FP4)). It's an enterprise version so we can't update it...polo31
Any idea what might cause this ? As you can see the HTML should have displayed correctly i don't understand why it is not !polo31
Well, mso-hightlight will definitely not work since "mso" attributes only work in Microsoft products. Have you tried it without the ConvertMIME=True assignment just before the Save call?Richard Schwartz
Oh ok I didn't know about that. Well it doesn't work either with the ConvertMIME=True assignment just before the Save call ... Still the same output.polo31

1 Answers

1
votes

The acid test is whether your HTML works if you send it to a Notes user. If it does what you want, then the Notes client can handle it and your code isn't sending what you think it should be. If it doesn't, then Notes can't handle that HTML construct and you need to find another way to do what you want.

Test your HTML by using Telnet to a Domino server on port 25, addressing it to your test user. There are lots of tutorials covering the basic technique. Most of them don't mention that (a) it's much easier to type the contents of your message into a file and paste it into your telnet window than to type it - followed by a couple of newlines and a line with a dot character and another newline, and (b) the content of your messages includes the standard headers and the mime headers so you have to learn a little bit about how those work if you don't already know.

Besides reading the relevant RFCs 2045 & 5322, the best way to learn qbout the headers is simply by examining the source of messages that you have received - e.g., via 'Show Original' in gmail, or View - Show - Page Source in Notes. Notes is pretty forgiving. The 'To:' and 'Subject:' and 'Date:' headers aren't required. The recipient will be determined by the 'RCPT TO' command, which comes before you enter the message. You will definitely need a content-type header specifying text/html;charset=iso-8859-1. Don't forget to put a blank line in between your last header line and the actual message content. (Note that for this purpose, you don't need to worry about setting up a multipart message and dealing with section boundaries, so if you're modeling after the source of a message you've received, look for one with just a simple content-type: text/html;charset=something header somewhere before the first blank line.)