[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Create and populate stationery in lotusscript

Posted on 2006-03-28
7
Medium Priority
?
2,355 Views
Last Modified: 2013-12-18
Hello -

Hoping I can get a good overview of how to go about doing the following.  I need to create a function that will allow users to create and save mail templates (stationery) in a database.  The users then need to be able to open mail received in this database, click a "template" button that will create a reply (with history) formatted with the template they selected.  I'd like to grab information from the email to use in populating the greeting (ie Dear <fromName>).

 - So far I have created a "template" form that has the following fields:
                  templateName
                  templateDescription
                  Body

- I have also created a button on the inbound email form that displays a picklist of the templates that can be used.  

After this I am kind of stuck as to how to create the reply memo using the body of the saved template.  Also, don't know how to get the history appended to this template.


I tried looking at the mail template for guidance, but the notes templates are a little too overdone for what I need and therefore more confusing than just doing it from scratch.  I would like a solution using lotusscript.


Thanks!
0
Comment
Question by:KDrago
  • 4
  • 3
7 Comments
 
LVL 18

Expert Comment

by:marilyng
ID: 16317284
Basically, your templates are responses, and in the FORM properties for these templates, VERY EASY,

Go to the SECOND tab
Check:  Formula inherits values from selected document
Check: Inherit entire document into Rich Text Field, then specify "Body" as your RT Field, and as "Collapsible Text"

check on close present mail send dialog.

No need for lotus script, unless you want to do other fancy things :)
0
 

Author Comment

by:KDrago
ID: 16325175
Hi marilyng -

Thanks for your response.  I have already developed most of this using lotusscript.  I am building the body field of a memo using field append text.  I am now trying to get the history appended to the end of the body field.  I have a handle on the open email.  I copy the entire uidoc using uidoc.select all and uidoc.copy.  Now I want to position and paste it to the end of the body field I have been formatting.  Is there anyway to do this?


Thanks again for your time.

Kim
0
 

Author Comment

by:KDrago
ID: 16325201
oh I should add I have uidoc.paste in my code after all of my body field text is entered.  It is placing the paste in a completely different field altogether.  I just don't know how to position the cursor to where I need it to paste
0
[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

 
LVL 18

Accepted Solution

by:
marilyng earned 2000 total points
ID: 16329573
KDrago,
Hmmm...let's see, usually when I do this, I build the entire document backend, and then open it front end.  (Which emulates how Notes does this when you press the "reply" button)

Anything is possible - just depends how elegant you want to be, and how much code you want to write :)

So, let's see.  

You have an email that appears in your database, and when opened, you have an action button that prompts the user to select a template to use.
Based on the template selected, you copy the currently opened email, open a new document, and paste the template body into the body field followed by the entire open document as history...

So, because the ability to navigate isn't available in ui, you would have to open the template, copy it, switch to the reply, paste that, add a few lines, switch back to the original email, copy that, then switch back to the reply and append that.  Not very elegant ;)

Simpler...

I hope your templates are separate documents.. if not, make them a separate form.. two fields:  Title (so you can recognize them) and rich text body, that contains the "body" of your pre-determined message.

Create a "Templates" view with one column - Title.

This script supposes that your "Reply" is a form with the name "Reply" and has the standard Body field, it also assumes that the opened email has the following fields: from, subject, body.

Put an action button on the email document called "Reply" and paste this into the script formula:

Sub Click(Source As Button)
    Dim Session As New NotesSession
    Dim db As NotesDatabase
    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Set db = session.currentdatabase
    Dim doc As NotesDocument
    Dim reply As NotesDocument
    Dim template As NotesDocument
    Set uidoc = ws.currentdocument
    Set doc = ws.currentdocument.document
    Dim richTitle As NotesRichTextStyle
    Dim richNormal As NotesRichTextStyle
    Set richTitle = session.CreateRichTextStyle    
    With richTitle
        .NotesFont = Font_helv
        .FontSize = 10
        .NotesColor = Color_blue
        .Bold = True
    End With    
   
    'Select template to use
    Dim coll As NotesDocumentCollection
    'Asks the user to select a template from the TEMPLATES view - some title in the first column to select
    Set coll = ws.PickListCollection( PICKLIST_CUSTOM,False,db.server,db.FileName,"Templates","Select a Template","Select a template to use")
    If coll.count<1 Then
        Msgbox "Sorry, you must select a template to use",,"No template selected"
        Exit Sub
    End If
    Set template = coll.GetFirstDocument
    If template Is Nothing Then
        Msgbox "Oops, the template you selected doesn't seem to be available",,"Unable to Continue"
        Exit Sub
    End If
    'This gets the template BODY item  and copies it
    Dim templateItem As NotesRichTextItem
    Set templateItem = template.GetFirstItem("Body")    
    Set reply =db.CreateDocument
    With reply
        .form = "Reply"
        .from = session.UserName
        .principal = session.UserName
        .sendTo = doc.from
        .subject = "Re: " + doc.subject(0)
        .makeresponse doc        
    End With
    Dim rtItem As New NotesRichTextItem(Reply,"Body")
    'Going to dump the current document into tmpbody so I can append it into a section
    Dim tmpItem As New NotesRichTextItem(Reply,"tmpBody")
    Call doc.RenderToRTItem (tmpItem)
    With rtitem
        .AddNewline 1,False
        If Not templateItem Is Nothing Then
            If templateitem.type = RICHTEXT Then
                .Appendrtitem templateItem
            Else
                Forall t In templateitem.Values
                    .appendText t                    
                End Forall                
            End If
        End If
        .AddNewline 2,False                
    End With
    'Appending history into a section in the reply....................................
    Dim colorObject As NotesColorObject
    Set colorObject = session.CreateColorObject
    colorObject.NotesColor = COLOR_Blue
    Call rtItem.BeginSection(doc.From(0), richTitle, colorObject, True)
    Call rtitem.AppendRTItem(tmpItem)
    Call rtItem.EndSection
    Call reply.MakeResponse (doc)
    'Now remove the tmpitem
    Call reply.RemoveItem("tmpItem")
    Call reply.computewithform(False, False)
    'Release Memory..................................
    Set templatedoc = Nothing
    Set doc = Nothing    
    uidoc.Close
    Set uidoc = ws.EditDocument(True, Reply)
   
End Sub

-------------------------------
There is little error trapping, and I've loosely formatted the history - you can indent it with a paragraph style.  If the currently opened email is not saved or is edited, then you may want to remark out the line: uidoc.close, since that will trigger a "do you want to save?"



0
 

Author Comment

by:KDrago
ID: 16332895
marilyng,

Thank you so much for your time and response.  This worked great.  if I could give you more than the 500 I would!

0
 

Author Comment

by:KDrago
ID: 16332986
I should also add that your explanations were so helpful and thorough.  Big help to a Lotus newbie like me.  I really can't say enough!
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16334650
You're welcome!
0

Featured Post

Receive 1:1 tech help

Solve your biggest tech problems alongside global tech experts with 1:1 help.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses
Course of the Month9 days, 16 hours left to enroll

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question