-2

I'm using IBM Designer 9.0, so I have a problem with sending notifications to notebooks.

I test this code which I find on the internet but it does not work.

Sub CreateMailNotification(doc As notesdocument, strSendTo As Variant, strSubject As String, strCopyTo As Variant)

  Dim session As notessession
  Dim db As notesdatabase
  Dim docMail As notesdocument
  Dim rtitem As Variant

  Set db = doc.parentdatabase
  Set session = db.Parent
  Set docMail=db.createdocument
  Set rtitem=docMail.CreateRichTextItem(“Body”)

  If strSendTo(0)=”” Then Exit Sub

  ‘=====set mail
  docMail.Form = “Memo”
  docMail.From = session.UserName
  docMail.Principle = session.UserName
  docMail.SendTo = strSendTo

  If Isarray(strCopyTo) Then
    If strCopyTo(0)<>”” Then
      docMail.CopyTo = strCopyTo
    End If
  Else
    If strCopyTo<>”” Then
      docMail.CopyTo = strCopyTo
    End If
  End If

  docMail.Recipients = strSendTo
  docMail.Subject = strSubject
  docMail.PostedDate = Now

  ‘=====set body field
  Call rtitem.AppendText(“Please click this doclink to see more details about the status ” + ” “)
  Call rtitem.AppendDocLink( doc, “click to open document”)
  Call rtitem.AddNewLine( 2 )

  ‘=====send mail
  Call docMail.send(False)
End Sub


call Call CreateMailNotification (doc, doc.nmSendTo, strSubject,doc.nmCopyTo)

I have a problem with these two lines

Call rtitem.AppendText(“Please click this doclink to see more details about the status ” + ” “) Call rtitem.AppendDocLink( doc, “click to open document”) Call rtitem.AddNewLine( 2 )

Tode
  • 11,795
  • 18
  • 34
NAFES
  • 1
  • 2
  • 1
    Do you have a default view and default form in your database ? – umeli Apr 24 '19 at 10:42
  • 1
    Add some errorhandler, then you get an errormessage, which you can use for further research... – umeli Apr 24 '19 at 10:44
  • 2
    I don't see a problem with this code (on a first glance). "I have a problem" is NOT a proper error description!!! – Tode Apr 24 '19 at 11:05
  • 1
    I agree with umeli ... set up an 'on error' and matching handler. The use of variants makes me cringe: please please please replace "Dim rtitem As Variant" with "Dim rtitem As NotesRichTextItem" – Robert Howe Apr 25 '19 at 15:43

1 Answers1

0

Typically an rtitem is a rich text item being referenced in the document. As has ben suggested before, you can do a simple error checking by doing an "onerror goto" or you can turn on the lotusscript debugger, "tools...\debug lotusscript", and step through the code (this is what I like), or you can do print statements at different places in your code: "print 1". That would display at the bottom on the status bar. Or you can even do a "messagebox( 'test')" to have a popup. Lots of options. The last two options I use all the time when debugging for the web. I use
Print "<Script Language = JavaScript>"
Print "alert('" + "Testing" + "')"
Print "</Script>"

This gives me places where i get prompts, and when they stop, somewhere after the last one and before the next one is where its crashing.

  • Sub CreateMailNotification Dim rt As NotesRichTextItem Set doc=curDb.CreateDocument doc.form="Memo" doc.Sendto="admin/is" doc.subject="Formulaire ajouté" Set rt=doc.CreateRichTextItem("Body") Call rt.AppendText("Bomjour") Call rt.AddNewline(2) Call rt.AppendDocLink(Masque.Document,"") Call doc.Send(False) End Sub I replaced with this code – NAFES Apr 26 '19 at 22:00