• Inserting into RichText - My solution

    By Dave Leigh 2 decades ago

    Rich text fields are a pain in the arse. Here are my problems and solutions… please comment.



    PROBLEMS:

    I've got several places where they have caused me consternation, as follows:

    1. Inserting signatures. VIC is not a modified mail template, however, it does do mail. This means I had to re-implement some of the mail features (and I have copied some of the script libraries from the R6 mail template for short-term expediency). One piece I re-implemented was inserting sigs. Originally this was done as in OverQuota; by opening the profile doc with the sig, cutting the sig to a clipboard, then pasting it into the Body field of the new mail. It's ugly, because you see the cutting and pasting happen.


    2. Inserting Library Docs. In VIC you can insert a Library Doc into a Journal Entry. These are pre-formatted body fields. The problem is the same as in 1… you see every thing happen… it's ugly and slow, and feels like a kludge.


    3. Forwarding/Replying to mail. Replying to mail wound up putting the whole of the original document in the body of the reply, which was exceedingly ugly and inconvenient.



      SOLUTIONS.

      These aren't perfect, but they're the best I've come up with so far. If anybody's got something better, I'd like to know, please!



      1 & 2: Work with RichText fields on the backend doc. I was avoiding this up to now because you HAVE to save the doc for the changes to be seen on the uidoc, and that leaves you with the nasty job of cleaning up after abandoned drafts. But I finally decided that the clean feel made it worth it. To keep from seeing the abandoned docs, I CREATE the docs with the deletion flag set on, and work with them in that state. When you save, send, or save as draft, then the deletion flag is turned off, but otherwise the document doesn't "exist" to the user. The end result is that it looks as if you'd been working with a normal uidoc, but there's none of the visible cutting and pasting into the body. The other benefits are that the signature doesn't get stomped on when you're doing replies, and the signature properly appears at the bottom of the body (unlike with cut and paste). It's clean with no flicker.



      3 (replying). I kept most of the reply the same way it was, because that saves a lot of time; but to fix the body problem I simply remove the body and re-copy it from the original doc. This removes all the extraneous garbage from the body that was put in by the Notes function. I can then cleanly convert that rich text over to Internet-style reply and add a sig and header. The end result is that replies just work as expected, and again, no more flicker.



      3 (forwarding). Mostly the same as above, but I don't convert that over to Internet style. I assume that you want to forward exactly what you got. One thing I'd like to do is put the original body in a collapsible section, but this hasn't worked for me in the limited time I've had to work on it. I wind up with an empty section followed by the forwarded richtext. If anyone can provide a solution I'd be grateful. In the meantime I simply preface the original with a header indicating that it's been forwarded.
    • Handling the "Reply with History" with a Notes Section...

      By Rob Breault/NC/Apisci 2 decades ago

      In the CratchitEmailLibrary -> sEmailReply sub-routine, I added the following code into the 'Non-Internet' style reply area. The trick was the "rtitem.Update".. without it the RT would NOT appear…





      Call replydoc.RemoveItem("Body")



      Set org_rtitem = currdoc.GetFirstItem("Body")

      Set rtitem = New NotesRichTextItem(replydoc,"Body")

      Set rtstyle = session.CreateRichTextStyle

      rtstyle.Bold = True

      Set rtcolor = session.CreateColorObject

      rtcolor.NotesColor = COLOR_DARK_GREEN



      Call rtitem.AddNewline(1)

      Call rtitem.BeginSection("—- Original Message —-", rtstyle, rtcolor, True)

      'This gives us a basic reply header….

      Call rtitem.AppendText(|From: "| & currdoc.ClientContact(0) & |" <| & currdoc.From(0) & |>| )

      Call rtitem.AddNewline(1)

      Call rtitem.AppendText(|Sent: | & Cstr(currdoc.PostedDate(0)) )

      Call rtitem.AddNewline(1)

      Call rtitem.AppendText(|To: | & Join(currdoc.SendTo,", ") )

      Call rtitem.AddNewline(1)

      If currdoc.CopyTo(0) <> "" Then

      Call rtitem.AppendText(|Cc: | &amp; Join(currdoc.CopyTo,&quot;, &quot;) )<br/>
      Call rtitem.AddNewline(1)<br/>
      

      End If

      Call rtitem.AppendText(|Subject: | & currdoc.Subject(0) )



      Call rtitem.AddNewline(2)

      Call rtitem.AppendRTItem(org_rtitem)

      Call rtitem.EndSection

      Call rtitem.Update

  • Thanks, much!

    By Dave Leigh 2 decades ago

    Thanks, Rob, YOU ROCK!



    Not only are you the first person to contribute a change, you solved a problem that's been bugging me big-time! In the next release there will be a user preference for this style. I don't think I'll make it selectable from the actionbar as in the Notes mail template, since I think people tend to pick one or the other and stick with it. I could change my mind if people think it makes more sense to do it Lotus' way.



    For anyone else wanting to patch this in, put Rob's code in place of my garbage in the Else clause of "If InternetStyle Then". Don't forget to declare the new objects Rob's using. Like so:

    Dim org_rtitem As NotesRichTextItem<br/>
    Dim rtstyle As NotesRichTextStyle<br/>
    Dim rtcolor As NotesColorObject<br/>
    



    and change the statement "InternetStyle = True" to "InternetStyle = False"

    • VIC Rocks!

      By Rob Breault 2 decades ago

      Actually you ROCK, for giving us a solid app from which to build on… But, I have actually done ALOT of changes… some of which are:


      • Moved almost all of the environment variables into a system wide database profile… (Now it is easier to work on both local and server replica copies and gives a global Enable/Disable to functionality still in progress)


      • Modified the "CratchitCommonLibrary" to support some global variables (database objects, preference settings, etc) for most scripts (works great with the above change)…


      • Made the "Import Email" agent a background agent for the client, so the updates (still user invoked) are not so invasive (my inbox is still 10K+ docs)


      • Modified the functions that grab values from the "User Preference" docs more "portable" so that the username can be passed into the (rather than totally relying on the session.CommonUserName, which will help us move the Import Email agent from the client to the server and add some server "notification" functionality…


      • Created a quick and dirty "Import SENT mail", so that previous outbound communications can be added and threaded accordingly…


      • Working on the "Forward Email" functionality now…



        Thanx again and it's great working with you…



        PS: Can we use Vic's image within the application? He ROCKS too!
      • Use of VIC Beaver.

        By Dave Leigh 2 decades ago

        Thanks, I'd like to see the changes. Let's make this better!



        Yep, you can use VIC Beaver, but I'd like to limit his use to things related to VIC CRM. I've got a few more images which I'll post up here and on my website. They're intended for (eventual) use in the documentation.



        Please keep in mind when doing changes that a MAJOR consideration is that there should be NO CHANGES to the Notes mail template. I've used other packages that "integrate" with Notes mail, with the result that you're locked into a specific version and can't effectively upgrade. It looks like you're already on that same wavelength, but it had to be said.