Solved

Lotus Notes HTML

Posted on 2002-06-24
11
1,113 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 
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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

860 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