Solved

Lotus Notes HTML

Posted on 2002-06-24
11
1,101 Views
Last Modified: 2007-11-27
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
Comment
Question by:danlevans
  • 7
  • 3
11 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 7105174
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
 
LVL 2

Author Comment

by:danlevans
ID: 7105321
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7105506
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
 
LVL 2

Author Comment

by:danlevans
ID: 7107640
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7107803
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7107889
The last code provided by you is for OLE not COM.
And the code in the question is for LotusScript not VB.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7107907
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7108448
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
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 100 total points
ID: 7122889
0
 
LVL 2

Author Comment

by:danlevans
ID: 7123590
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
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7125523
Thanks for "A" grade.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now