Link to home
Start Free TrialLog in
Avatar of shuboarder
shuboarderFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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!
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

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; "")
Avatar of shuboarder

ASKER

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
> doc.SendTo = doc.ReturnReceiptTo

Where do you think doc.ReturnReceiptTo should come from?? The object doc is a newly created document...
From the current document (received email) into a new document (new email)?
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
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
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??
Because I want it to be a new email?
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
SOLUTION
Avatar of marilyng
marilyng

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
1) That's the 0.01%  :(
2) To Marilyn: who says there's only one address in ReturnReceiptTo ??
Avatar of marilyng
marilyng

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.
LOL

Shuboarder, if you want us to explain, please say so...
Yes please!

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

I'm getting an object variable not set.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.

SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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. :)
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...?
Thanks Sjef, I will!