Help with doc.sendto lotus script

I am trying to call the following from a button that is sent in an email.

Sub Sender
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      
      Set db = s.CurrentDatabase
      Set doc = New NotesDocument(db)
      doc.SendTo = doc.ReturnReceipt
      doc.Subject = "Locations Processed"
      doc.Body = "I have processed the button you sent"
      doc.Send False
End Sub

Once the button is pressed I want an email to be sent to the names in the ReturnReceipt field
If the field is null I want it to not error out.

At the moment all I get is the following error:

Notes Error: No names found to send mail to

The ReturnReceipt field is a computed names field on a form with the following formula:

@If(
confirm = "Yes"; (@UserName);
confirm = "No"; "";
"")

The confirm field is a radio button with the options of Yes or No

Notes client 6.5

Any help much appreciated!
LVL 21
shuboarderAsked:
Who is Participating?
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
Your current code please... Oh, what the heck... MOOZAKALA!!

Sub Sender
     Dim s As New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Dim ws As New NotesUIWorkspace
     Dim curdoc As NotesDocument
     
     Set db = s.CurrentDatabase
     Set doc = New NotesDocument(db)
     Set curdoc= ws.CurrentDocument.Document
     doc.SendTo = curdoc.ReturnReceiptTo ' <- this line
     doc.Subject = "Locations Processed"
     doc.Body = "I have processed the button you sent"
     doc.Send False
End Sub
0
 
Sjef BosmanGroupware ConsultantCommented:
The field ReturnReceipt is internall used by Notes, set to "1" when the sender would like to get a return receipt. Out of a million applicable names, did you really have to pick that one? ;)

Suggested name:
    ReturnReceiptTo
with formula
    @If(confirm = "Yes"; @UserName; "")
0
 
shuboarderAuthor Commented:
Thanks Sjef.... trust that to happen!

Still getting the same message however...

Sub Sender
     Dim s As New NotesSession
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     
     Set db = s.CurrentDatabase
     Set doc = New NotesDocument(db)
     doc.SendTo = doc.ReturnReceiptTo
     doc.Subject = "Locations Processed"
     doc.Body = "I have processed the button you sent"
     doc.Send False
End Sub
0
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

 
Sjef BosmanGroupware ConsultantCommented:
> doc.SendTo = doc.ReturnReceiptTo

Where do you think doc.ReturnReceiptTo should come from?? The object doc is a newly created document...
0
 
shuboarderAuthor Commented:
From the current document (received email) into a new document (new email)?
0
 
Sjef BosmanGroupware ConsultantCommented:
Something like ALAKAZOOM and there's the current document?? It don't go that way. You have to use the NotesUIWorkspace to get to the current document, like this

    Dim ws As New NotesUIWorkspace
    Dim curdoc As NotesDocument

    Set curdoc= ws.CurrentDocument.Document

...etc
0
 
shuboarderAuthor Commented:
I realised that the coding was probably pretty poor... Besides ALAKAZOOM is more of a Microsoft command ;)
 
any particular order to declare things or does it not matter as long as it is declared before setting?
Still struggling....

Sub Sender
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim ws As New NotesUIWorkspace
      Dim curdoc As NotesDocument
      
      Set db = s.CurrentDatabase
      Set doc = New NotesDocument(db)
      Set curdoc= ws.CurrentDocument.Document
      doc.SendTo = doc.ReturnReceiptTo
      doc.Subject = "Locations Processed"
      doc.Body = "I have processed the button you sent"
      doc.Send False
End Sub
0
 
Sjef BosmanGroupware ConsultantCommented:
Yeah, that's the 99% I gave, now you need to find out the 1% that's left to do. I'll give you again 99% of this 1%, effectively going to 99.99% of the solution.

Key question: if you want to get a value from the current document, why do you use the new document??
0
 
shuboarderAuthor Commented:
Because I want it to be a new email?
0
 
shuboarderAuthor Commented:
Ok.... still not got it.
am I any closer?

Sub Sender
      Dim s As New NotesSession
      Dim ws As New NotesUIWorkspace
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim uidoc As NotesUIDocument
      
      Set db = s.CurrentDatabase
      Set uidoc = ws.CurrentDocument
      doc.SendTo = doc.ReturnReceiptTo
      doc.Subject = "Locations Processed"
      doc.Body = "I have processed the button you sent"
      doc.Send False
End Sub
0
 
marilyngConnect With a Mentor Commented:
 Set db = s.CurrentDatabase
     Set doc = New NotesDocument(db)
     Set curdoc= ws.CurrentDocument.Document
     doc.SendTo = CURDOC.ReturnReceiptTo(0)   <<<<Here is your problem, that is if curdoc is something.


     Set curdoc= ws.CurrentDocument.Document
   if len(curdoc.ReturnReceiptTo(0))> 0 then
     doc.SendTo = CURDOC.ReturnReceiptTo(0)   '<<<<Here is your problem, that is if curdoc is something.
   else
      'Alternative fall back name
        doc.sendTo="This Fall Back Name"
   end if

0
 
Sjef BosmanGroupware ConsultantCommented:
1) That's the 0.01%  :(
2) To Marilyn: who says there's only one address in ReturnReceiptTo ??
0
 
marilyngCommented:
Of course there can be more than one ReturnReceiptTo, so just take the (0) off the end.  You advised right, but shuboarder forgot to change the doc ReturnReceiptTo to something that contained something.

oh, darn, did I stomp on your attempt to get shuboarder to figure it out?  So, sorry, I just now read the top of your comments.
0
 
Sjef BosmanGroupware ConsultantCommented:
LOL

Shuboarder, if you want us to explain, please say so...
0
 
shuboarderAuthor Commented:
Yes please!

I do need to learn all this stuff.
0
 
shuboarderAuthor Commented:
BTW I still can't get this to work!

I'm getting an object variable not set.
0
 
shuboarderAuthor Commented:
Thanks Sjef,

I'd say thanks for trying to help me get it on my own as well except for the fact I spent way too long on it yesterday and got nowhere. Without a full understanding of Lotus Script it is still very much a case of trial and error for me.

0
 
Sjef BosmanConnect With a Mentor Groupware ConsultantCommented:
The lecture...

What you need to understand is the idea of an object: it's a "living" thing, in memory, with properties and methods. Take a NotesDocument: it has properties (Created, Modified) and methods (GetItemValue) that work on the object in question. It is NOT a physical document in the database on disk, it is merely a representation of a physical document. Hence the Save-method, to write all changes back in the database.

Two starting objects are a NotesUIWorkspace for on-screen work, and NotesSession. Many form events have a Source parameter that is a NotesUIDocument, an active/foreground representation of a NotesDocument. These are the main objects you have to start with. All other objects can be obtained through these three. You have to study the Domino Object Model carefully. Also compare NotesDocument and NotesUIDocument.

In this case, you needed two objects to work with: the current document and a mailable document. Now, the current document only exists in a UI-environment, so you can get the workspace (New NotesUIWorkspace), then the current foreground document (CurrentDocument), then the current background document (Document). That document contained ReturnReceiptTo, and you copied it ti the mailable document using  
    doc.SendTo = curdoc.ReturnReceiptTo ' <- this line
which is functionally equivalent to
    Call doc.ReplaceItemValue("SendTo", curdoc.GetItemValue("ReturnReceiptTo"))
As in many OO languages, the property-like assignment is a synonym for some value assignment method.

If you want more, then may I suggest you get a good book on Notes/Domino programming?

0
 
shuboarderAuthor Commented:
Hi Sjef,

thanks for the explanation. I already have a book called Lotus Notes and Domino 6 Programming by Benz Oliver.
It's useful to an extent as is your explanation in that I understand fully what you are saying.
However, the actual practicality of it is much more difficult for me.

I suppose a lot of it is just down to experience and repetition. :)
0
 
Sjef BosmanGroupware ConsultantCommented:
There was this painter on television. Every now and then, he took all the paintings from the last few months, looked at them very carefully with his expert eyes, and then he happily put 70% of his paintings into a fire. When asked why he did so, he answered that these paintings weren't good enough to be sold. But they needed to be painted anyway, because he couldn't paint only good paintings.

May I suggest you go on painting, and painting, and painting...?
0
 
shuboarderAuthor Commented:
Thanks Sjef, I will!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.