I have a script that builds and email …the email is built off mutiple documents that each have one or more sections in a rich text field on them. The emails goes through and appends each rich text field from all the documents and then sends the email. The issue is there are mutiple blank lines after each section is added to the new email from the underlying document. How can we get rid of these extra lines??? They arent in the underlying documents…
Subject: appending rich text and getting mutiple spaces between sections
Hard to tell, if we don’t know nothing about your code. Is this Notes only email?
Subject: RE: appending rich text and getting mutiple spaces between sections
Its a notes only email. The code just takes one rich text field from the original doc and appends to the body of the email…and then goes to the next doc and gets that rich text field and appends…etc
Subject: RE: appending rich text and getting mutiple spaces between sections
here is the code the part of the code we append the rich text: If Not (LookUpDoc Is Nothing) Then
LineCtr = LineCtr + 1
Set rtitemA = MailDoc.GetFirstItem( "Instruction" )
Set rtitemB = LookUpDoc.GetFirstItem( "Instructions" )
If ( rtitemA.Type = RICHTEXT And rtitemB.Type = RICHTEXT ) Then
Call rtitemA.AppendRTItem( rtitemB )
'Call rtitemA.AddNewLine(1)
'Call rtitemA.AddNewLine(1)
Call rtitemB.Remove
Call CDoc.Save( False, True )
End If
End If
Here is the fill code:
Sub Build_Response_Email (CDoc As NotesDocument , UICurrDoc As NotesUIDocument )
Dim s As New NotesSession
Dim CurrDb As NotesDatabase
Dim MailDoc As NotesDocument
Dim LookUpDoc As NotesDocument
Dim ResponseDoc As NotesDocument
Dim viewLookup As NotesView
Dim Key As String
Dim rtitemA As Variant
Dim rtitemB As Variant
Dim rtitemC As Variant
Dim rtitemD As Variant
Dim LineCtr As Integer
Dim Answer As String
Dim rtitem As NotesRichTextItem
Dim EmailWasSent As Boolean
Dim ws As New NotesUIWorkspace
EmailWasSent = False
Set CurrDb = s.CurrentDatabase
Set ResponseDoc = UICurrDoc.Document
Set MailDoc = New NotesDocument (CurrDb)
MailDoc.Form = "fmResponseEmail"
MailDoc.Principal = "Beacon Generator"
MailDoc.SendTo = CDoc.OriginalAuthor(0)
MailDoc.Subject = "Beacon form for " & CDoc.documentType(0)
LineCtr = 0
Set rtitem = MailDoc.CreateRichTextItem( "Instruction")
Set viewLookup = CurrDb.GetView ("vInstructionsCreated")
For i = 1 To 20
Answer = ResponseDoc.GetItemValue( "ans" & i )(0)
If Answer = "Yes" Then
Key = Ucase (ResponseDoc.documentType(0) ) & "@@" & i
Set LookUpDoc = viewLookup.GetDocumentByKey ( Key )
If Not (LookUpDoc Is Nothing) Then
LineCtr = LineCtr + 1
Set rtitemA = MailDoc.GetFirstItem( "Instruction" )
Set rtitemB = LookUpDoc.GetFirstItem( "Instructions" )
If ( rtitemA.Type = RICHTEXT And rtitemB.Type = RICHTEXT ) Then
Call rtitemA.AppendRTItem( rtitemB )
'Call rtitemA.AddNewLine(1)
'Call rtitemA.AddNewLine(1)
Call rtitemB.Remove
Call CDoc.Save( False, True )
End If
End If
End If
Next
If LineCtr > 0 Then 'Send regurlar message
Set viewLookup = CurrDb.GetView ("vQuestionsCreated")
Set rtitem = MailDoc.CreateRichTextItem( "OpeningParagraph")
Key = Ucase (ResponseDoc.documentType(0) )
Set LookUpDoc = viewLookup.GetDocumentByKey ( Key )
If Not (LookUpDoc Is Nothing) Then
Set rtitemA = MailDoc.GetFirstItem( "OpeningParagraph")
Set rtitemB = LookUpDoc.GetFirstItem( "OpeningParagraph" )
If ( rtitemA.Type = RICHTEXT And rtitemB.Type = RICHTEXT ) Then
Call rtitemA.AppendRTItem( rtitemB )
Call rtitemB.Remove
Call CDoc.Save( False, True )
End If
Set rtitem = MailDoc.CreateRichTextItem( "ClosingParagraph")
Set rtitemC = MailDoc.GetFirstItem( "ClosingParagraph")
Set rtitemD = LookUpDoc.GetFirstItem( "ClosingParagraph" )
If ( rtitemC.Type = RICHTEXT And rtitemD.Type = RICHTEXT ) Then
Call rtitemC.AppendRTItem( rtitemD )
Call rtitemD.Remove
Call CDoc.Save( False, True )
End If
End If
MailDoc.Send (True)
EmailWasSent = True
Else 'Send message with default form
Set viewLookup = CurrDb.GetView ("vQuestionsCreated")
Set rtitem = MailDoc.CreateRichTextItem( "DefaultParagraph")
Key = Ucase (ResponseDoc.documentType(0) )
Set LookUpDoc = viewLookup.GetDocumentByKey ( Key )
If Not (LookUpDoc Is Nothing) Then
Set rtitemA = MailDoc.GetFirstItem( "DefaultParagraph")
Set rtitemB = LookUpDoc.GetFirstItem( "DefaultParagraph" )
If ( rtitemA.Type = RICHTEXT And rtitemB.Type = RICHTEXT ) Then
Call rtitemA.AppendRTItem( rtitemB )
Call rtitemB.Remove
Call CDoc.Save( False, True )
End If
End If
MailDoc.Send (True)
EmailWasSent = True
End If
If EmailWasSent Then
askmeOK = ws.Prompt (PROMPT_OK, "Beacon submission received.", "Please check your Lotus Notes email for your customized Beacon form.")
End If
End Sub