[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1157
  • Last Modified:

Lotus Notes HTML

I need to send Lotus Notes with HTML. I found the following code:

Sub Initialize    
    Dim session As New NotesSession
    Dim db As NotesDatabase
    Set db = session.CurrentDatabase
    Dim doc As New NotesDocument(db)
    Call doc.AppendItemValue("From", session.UserName)
    Call doc.AppendItemValue("Subject", _
    "Meeting time changed")
    Dim richStyle As NotesRichTextStyle
    Set richStyle = session.CreateRichTextStyle
    Dim richText As New NotesRichTextItem(doc, "Body")
    richStyle.PassThruHTML = True
    Call richText.AppendStyle(richStyle)
    Call richText.AppendText("<B>Hello</B>")
    Call doc.Save(True, False)
End Sub

I get an error on all statements using "as new" like:

    Dim richText As New NotesRichTextItem(doc, "Body")

What am I doing wrong?
0
danlevans
Asked:
danlevans
  • 7
  • 3
1 Solution
 
Arthur_WoodCommented:
I was not aware the Notes supported parameterized Object constructors.  Notes is based an VBA, and VBA DOES NOT Allow parametrized constructors such as

Dim doc As New NotesDocument(db)


Rather, you must

Dim doc As New NotesDocument

Then assign the db to the newly created doc object with code along these lines:

set Doc.Database = db

This would apply to EVERY instance of the DIM where you are attempting to use a parameterized constructor.

Arthur Wood
0
 
danlevansAuthor Commented:
Arthur,
 I am attempting this outside of Notes with a vb program using Lotus Notes automation classes reference. My complile does not like the statement

Dim doc As New NotesDocument

The error indicates a invalid use of New keyword
0
 
Richie_SimonettiIT OperationsCommented:
The only New statement that you can use is for Session object.
Just use ... as NotesDocument.
Take a look on how to create mail in notes at:
www.angelfire.com/realm/vb-shared/index.html under "Say OLE to Notes..." topic.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
danlevansAuthor Commented:
Richie,

I added the changes your url suggested with the following result:

Private Sub Form_Load()

   

    'Dim session As New NOTESSESSION

    Dim session As Object

    Set session = CreateObject("Notes.Notessession")

   

    Dim db As Object

    Set db = session.CURRENTDATABASE

   

    'Dim doc As New NotesDocument(db)

    Dim doc As Object

    Set doc = db.CREATEDOCUMENT

   

    Call doc.APPENDITEMVALUE("From", session.USERNAME)

    Call doc.APPENDITEMVALUE("Sendto", session.USERNAME)

    Call doc.APPENDITEMVALUE("Subject", _

    "Meeting time changed")

    Dim richStyle As Object

    Set richStyle = session.CREATERICHTEXTSTYLE

   

    'Dim richText As New NotesRichTextItem(doc, "Body")

    Dim richtext As Object

    Set richtext = doc.CREATERICHTEXTITEM("BODY")

   

    richStyle.PASSTHRUHTML = True

    Call richtext.APPENDSTYLE(richStyle)

    Call richtext.APPENDTEXT("<B>Hello</B>")

    Call doc.SEND(False)

    Call doc.SAVE(True, False)

End Sub

The job will run but the passthruhtml desired is not there.
Any Ideas? I will double the points
0
 
Richie_SimonettiIT OperationsCommented:
Well, i don't know really. The problem was with "New" keyword for NotesDocument. Just take this mind: Some exposed object are not available to VB but LotusScript. I mean, there few Objects that are not inplemented to use with VB, only with LS. Maybe it is one of them.
Anyway, i will do a little research...
0
 
Richie_SimonettiIT OperationsCommented:
The last code provided by you is for OLE not COM.
And the code in the question is for LotusScript not VB.
0
 
Richie_SimonettiIT OperationsCommented:
Could be usefull if you attach a html file instead of create it in NotesDocument?
I saw in the net that there is a problem in PassThruHTML with VB.
0
 
Richie_SimonettiIT OperationsCommented:
I created the following code from the site posted earlier.
It has a problem as you pointed, if you set PassThruHTML to false everything is OK but if you set to True, error raises!!

Private Sub cmdSend_Click()
Dim Doc As NotesDocument
Dim NItem As NotesRichTextItem
Dim RichStyle As NotesRichTextStyle

'Creates new document/message
Set Doc = COMDB.CreateDocument
    With Doc
        ' Creates Rich body item and adds all headers
        Set NItem = Doc.CreateRichTextItem("BODY")
        .AppendItemValue "Form", "memo"
        .AppendItemValue "SendTo", Text1(0).Text
        .AppendItemValue "CopyTo", Text1(1).Text
        .AppendItemValue "Subject", Text1(2).Text
        .AppendItemValue "BODY", Text1(3).Text
        Set RichStyle = COMSess.CreateRichTextStyle
        'RichStyle.PassThruHTML = Not False ' ????
        RichStyle.PassThruHTML = True ' error!!!
        Call NItem.AppendStyle(RichStyle)
        Call NItem.AppendText("<b><i>hello world</i></b>")

        .Send False
    End With

End Sub


0
 
Richie_SimonettiIT OperationsCommented:
0
 
danlevansAuthor Commented:
Richie,

Thanks, it wasn't what I was looking for but it is the answer to the question. I will have to live with attachments.

dan
0
 
Richie_SimonettiIT OperationsCommented:
Thanks for "A" grade.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 7
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now