Solved

Lotus Notes HTML

Posted on 2002-06-24
11
1,105 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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Specify ip address in my connection string for sas 2 59
Sending a email via excel using vba 6 79
passing a value with stream reader AFTER a ";" 3 66
RUNRMTCMD from AS/400 12 44
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

808 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