Hi, I´m just a beginner in using lotus script.
The following szenario: a document changes the status and now I want to send an email with this information.
Sending the email is not the problem.
The problem is the recipient.
I want to take the username (field: f_Username) in the sendTo Field.
But I get the error “object variable not set”
Here´s the script:
Sub statusänderung
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim item As NotesItem
Set db = session.CurrentDatabase
Set newdoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newdoc, "Body" )
newdoc.Form = "Memo"
newdoc.SendTo = doc.f_Username
newdoc.Subject = "Hallo"
Call rtitem.AppendText( "XXXX...." )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText("XXXX...")
Call rtitem.AddNewLine( 2 )
Call newdoc.Save( False, True )
Call newdoc.Send( True)
End Sub
I hope somebody can help me.
Stefanie
Subject: "Object variable not set " problem with script code
Stefanie,
I think the error is occuring on the line “newdoc.SendTo = doc.f_Username”.
You do not appear to have set the doc and also, the correct syntax would be doc.f_Username(0).
HTH
Mike
Subject: RE: "Object variable not set " problem with script code
Hi,thank´s for your answer.
I´ve changed the line, but I get the same error-message.
What do you mean with “have set the doc…”.
Here´s my actual code:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim newdoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim item As NotesItem
Set db = session.CurrentDatabase
Set newdoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( newdoc, "Body" )
newdoc.Form = "Memo"
newdoc.SendTo = doc.f_Username
newdoc.Subject = "Hinweis"
Call rtitem.AppendText( "Ihre IT Support Anfrage" )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText("Thema der Support Anfrage: ")
Call rtitem.AddNewLine( 2 )
Call newdoc.Save( False, True )
Call newdoc.Send( True)
Thanks in advance.
Stefanie
Subject: RE: "Object variable not set " problem with script code
…sorry I´ve changed the linenewdoc.SendTo = doc.f_Username
to
newdoc.SendTo = doc.f_Username(0) and I get the error-message instead.
Subject: RE: "Object variable not set " problem with script code
I realise that - so what’s your code now - have you set doc now?
Subject: RE: "Object variable not set " problem with script code
What he was saying is that, while you have a set db line, and a set newdoc line, you haven’t set doc at all (hope that makes sense).
What is the doc that you’re getting the f_Username from? Is it the current, open document? If so you need to set it like this:
dim w as new notesuiworkspace
dim uidoc as notesuidocument
set uidoc = w.currentdocument
dim doc as notesdocument
set doc = uidoc.document
Also, is f_Username a single value field only? If so, then the code will will with f_Username(0), otherwise you’ll have to change that to retrieve each value out of the field separately.
hth
Dan
Subject: RE: "Object variable not set " problem with script code
Thank you very much; that´s it.