Solved

Lotus Notes HTML

Posted on 2002-06-24
11
1,124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

690 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