Solved

Help with doc.sendto lotus script

Posted on 2006-06-13
21
1,350 Views
Last Modified: 2013-12-18
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!
0
Comment
Question by:shuboarder
  • 10
  • 9
  • 2
21 Comments
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16893599
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
 
LVL 21

Author Comment

by:shuboarder
ID: 16893675
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16894319
> doc.SendTo = doc.ReturnReceiptTo

Where do you think doc.ReturnReceiptTo should come from?? The object doc is a newly created document...
0
 
LVL 21

Author Comment

by:shuboarder
ID: 16894714
From the current document (received email) into a new document (new email)?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16894819
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
 
LVL 21

Author Comment

by:shuboarder
ID: 16894966
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16895067
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
 
LVL 21

Author Comment

by:shuboarder
ID: 16895247
Because I want it to be a new email?
0
 
LVL 21

Author Comment

by:shuboarder
ID: 16895559
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
 
LVL 18

Assisted Solution

by:marilyng
marilyng earned 100 total points
ID: 16896074
 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16898402
1) That's the 0.01%  :(
2) To Marilyn: who says there's only one address in ReturnReceiptTo ??
0
 
LVL 18

Expert Comment

by:marilyng
ID: 16898701
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16900278
LOL

Shuboarder, if you want us to explain, please say so...
0
 
LVL 21

Author Comment

by:shuboarder
ID: 16900620
Yes please!

I do need to learn all this stuff.
0
 
LVL 21

Author Comment

by:shuboarder
ID: 16900878
BTW I still can't get this to work!

I'm getting an object variable not set.
0
 
LVL 46

Accepted Solution

by:
Sjef Bosman earned 150 total points
ID: 16901156
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
 
LVL 21

Author Comment

by:shuboarder
ID: 16901320
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
 
LVL 46

Assisted Solution

by:Sjef Bosman
Sjef Bosman earned 150 total points
ID: 16902139
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
 
LVL 21

Author Comment

by:shuboarder
ID: 16942244
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16948919
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
 
LVL 21

Author Comment

by:shuboarder
ID: 16949235
Thanks Sjef, I will!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now