Lotus IBM
--
Questions
--
Followers
Top Experts
Here is some code I am using to send some mail.
Sub Click(Source As Button)
      Stop
      Dim LF As String
      Dim ws As New notesuiworkspace
      Dim uidoc As notesuidocument
      Dim doc As notesdocument
      Dim i As Integer
      Dim e1 As String
     Â
      Dim t1 As String
      Dim t2 As String
     Â
      Dim flag As Integer
      Dim SendTo As Variant
      Dim CopyTo As String
      Dim BlindCopyTo As String
      Dim WebSubject As String
      Dim body As String
      Dim wmail As String
     Â
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.document
      LF=Chr$(13)+Chr$(10)
      e1 = "Requested:  "+uidoc.fieldgettext("Req_
      doc.inheritedsubject = uidoc.document.subject(0)
     Â
      t1 = ""
     Â
     Â
      t2 = Inputbox("Enter Any Pertinent Information for the Requestor", "")
     Â
      If Ltrim$(t2) = "" Then
           Exit Sub
      End If
     Â
     Â
      Sendto = ws.pickliststrings(PICKLIS
      If Isempty(Sendto) Then
      Exit Sub
      End If
     Â
      CopyTo = ""
      BlindCopyTo = ""
      WebSubject = "Your VM Ware request is Complete "+doc.inheritedsubject(0)
      'WebSubject = "The Project Charter has changed"
      body = "Here is a link to the Original Ticket:  "+t2
      wmail = "Double Click this link to access the document -->"
      i = Lbound(sendto)
      For i = Lbound(sendto) To Ubound(sendto)
           flag% = SendMailMemo(sendto(i),Cop
      Next
      If (flag%) Then
           Messagebox "The person or persons you selected have been notified"
      Else
           Messagebox "The mail notification failed to send properly.  "           Â
      End If
End Sub
What this does is:
1. Opens a dialog box for the user to add comments
2. Opens the address book so the user can select from the NAB
3. Sends an email with a doclink and comments
What I need instead of the NAB opening up is to be able to send it to the req_requestor field. This field contains the name of the person submitting the request. So the user enters the comments and once the click on "OK" the email is sent and the NAB does not open.....
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
cheers,
Tom






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
cheers,
Tom
Sendto = uidoc.document.req_Request

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
@trim(@unique( REQ_Requestor:REQ_Notify))
Your script then must have a uidoc.refresh() in it, to force the computation of this formula.
 A very easy way of doing this, however, is to assume you are working with single value fields, then it looks like this :
Sendto = uidoc.document.req_Request
cheers,
Tom
You could put the code you  have in the QuerySave event, so it's executed  as someone saves the document.
Change this
  Set uidoc = ws.CurrentDocument
   Set doc = uidoc.document
(and change all occurences of "uidoc" to "source")
To
Call source.refresh()
set doc = source.document
And the sendto line , to
Sendto = source.document.REQ_Notify
cheers,
Tom






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Change this
  Set uidoc = ws.CurrentDocument
   Set doc = uidoc.document
Change it to what?
Set source = ws.currentDocument
Set doc = source.document
????
if source.document.Status(0) = "Completed" then
' send the mail
....
end if
Ah, and for the Req_NotifyAll field, make sure the property "Allow multiple values" is checked. Â
If you don't want the inputbox, Â just delete it (or put a single quote in front of it, to comment it out, like this:
'this would be comment
cheers,
Tom
Sub Click(Source As Button)
   Stop
   Dim LF As String
   Dim ws As New notesuiworkspace
*****Dim Source As notesuidocument#####
   Dim doc As notesdocument
   Dim i As Integer
   Dim e1 As String
  Â
   Dim t1 As String
   Dim t2 As String
  Â
   Dim flag As Integer
   Dim SendTo As Variant
   Dim CopyTo As String
   Dim BlindCopyTo As String
   Dim WebSubject As String
   Dim body As String
   Dim wmail As String
  Â
*****Set source = ws.CurrentDocument
*****Set doc = source.document
   LF=Chr$(13)+Chr$(10)
*****e1 = "Requested: Â "+source.fieldgettext("Req
*****doc.inheritedsubject = Source.document.subject(0)
******if source.document.Status(0) = "Completed" then
******' send the mail
******....
******end if
  Â
   t1 = ""
  Â
  Â
***** 't2 = Inputbox("Enter Any Pertinent Information for the Requestor", "")
  Â
   If Ltrim$(t2) = "" Then
     Exit Sub
   End If
  Â
  Â
****Sendto = uidoc.document.req_NotifyA
   If Isempty(Sendto) Then
   Exit Sub
   End If
  Â
   CopyTo = ""
   BlindCopyTo = ""
   WebSubject = "Your VM Ware request is Complete "+doc.inheritedsubject(0)
  *****body = "Here is a link to the Original Ticket:  " '+t2
   wmail = "Double Click this link to access the document -->"
   i = Lbound(sendto)
   For i = Lbound(sendto) To Ubound(sendto)
     flag% = SendMailMemo(sendto(i),Cop
   Next
   If (flag%) Then
     Messagebox "The person or persons you selected have been notified"
   Else
     Messagebox "The mail notification failed to send properly.  "     Â
   End If
End Sub
I get errors where there are #### after the line.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
 Stop
   Dim LF As String
   Dim doc As notesdocument
   Dim i As Integer
   Dim e1 As String
  Â
   Dim t1 As String
   Dim t2 As String
  Â
   Dim flag As Integer
   Dim SendTo As Variant
   Dim CopyTo As String
   Dim BlindCopyTo As String
   Dim WebSubject As String
   Dim body As String
   Dim wmail As String
  Â
Set doc = source.document
   LF=Chr$(13)+Chr$(10)
e1 = "Requested: Â "+source.document.Req_VMNa
doc.inheritedsubject = Source.document.subject
if source.document.Status(0) = "Completed" and source.document.REQ_MailSe
' send the mail
   t1 = ""
   't2 = Inputbox("Enter Any Pertinent Information for the Requestor", "")
    '  If Ltrim$(t2) = "" Then
  '    Exit Sub
  '  End If
  Â
  Â
Sendto = uidoc.document.req_NotifyA
   If Isempty(Sendto) Then
   Exit Sub
   End If
  Â
   CopyTo = ""
   BlindCopyTo = ""
   WebSubject = "Your VM Ware request is Complete "+doc.inheritedsubject(0)
 body = "Here is a link to the Original Ticket:  "
   wmail = "Double Click this link to access the document -->"
   i = Lbound(sendto)
   For i = Lbound(sendto) To Ubound(sendto)
     flag% = SendMailMemo(sendto(i),Cop
   Next
   If (flag%) Then
     Messagebox "The person or persons you selected have been notified"
   Else
     Messagebox "The mail notification failed to send properly.  "     Â
   End If
source.document.REQ_MailSe
else
print "not sending mail, request not complete."
end if
End Sub

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
if source.document.Status(0) = "Completed" and source.document.REQ_MailSe
to
if source.document.Status(0) = "Completed" and not(source.document.hasIte
cheers,
Tom






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Option declare
You'll get errors about variables and functions that are  not declared properly.
Also, run the code in the debugger (file/tools/debug lotusscript and then create a test document). Â Step through the code, and see where it goes wrong.
cheers,
Tom
Option Declare??? Is this on the Globals? or there is the options and there is a declarations....
Sorry dude, I am looking for a good course on Lotus script, if you know of any let me know.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Function SendMailMemo(sendTo As String, _
cc As String, _
bcc As String, _
subject As String, _
body As String, _
linkTo As Variant, _
linkurl As String) As Integer
' Â Â Â Â Â flag% = SendMailMemo("SendTo", "cc", "bcc", "Subject", "Body Text", NotesDocument)
      Stop
      'On Error Goto ErrorHandler
      On Error Resume Next
     Â
      Dim mailDb As New NotesDatabase("", "")
      Dim mailDoc As NotesDocument
      Dim rtItem As NotesRichTextItem
      Dim Doc As NotesDocument
     Â
     Â
      Call mailDb.OpenMail
      If (mailDb.IsOpen = False) Then Call mailDb.Open("", "")
      Set mailDoc = mailDb.CreateDocument
      Maildoc.Principal="""VM Ware Request"" <DO NOT RESPOND>"
      mailDoc.Form = "Memo"
      mailDoc.SendTo = Sendto
      mailDoc.CopyTo= cc
      mailDoc.BlindCopyTo = bcc
      mailDoc.Subject = subject
      Set rtItem = mailDoc.CreateRichTextItem
      Call rtItem.AppendText(body)
      If Not(linkTo Is Nothing) Then
           Call rtItem.AddNewLine(2)
           Call rtItem.AppendDocLink(linku
      End If
      If Not(linkurl ="") Then
           Call rtItem.AddNewLine(2)
           Call rtitem.AppendText(linkurl)
          Â
           Call rtitem.AppendDocLink(linkt
      End If
      Call mailDoc.Send(False)
      SendMailMemo = True
      Exit Function
     Â
ErrorHandler:
      Print "Error " & Str$(Err) & ": " & Error$
      Resume TheEnd
     Â
TheEnd:
      SendMailMemo = False
End Function     Â
This was created when I pasted the code into the Query save event. The debugger only runs the code you posted here....
If your script doesn't reach the function  (the calling of the fucntion), something else is probalby wrong.  Check  with the debugger where he ends (is it the  if statement ?)
cheers,
Tom

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
    '  If Ltrim$(t2) = "" Then
  '    Exit Sub
  '  End If
just to see if it would prompt me but it doesn't make it that far. Whne I click on the save and close the form just seems to close.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
if source.document.Status(0) = "Completed" and not(source.document.hasIte
source.document.REQ_MailSe
else
print "not sending mail, request not complete."
end if
and it worked...........small problem, now it wants to send the email everytime the document is closed, I just need it to send when the Req_Status is complete......could this be because the query save actually runs before the document is saved? Can I put something on the Save/Close button so that the form is saved then the querysave runs????
But that's not the issue. Â After sending the mail and saving the document the first time, the document should have received a new field REQ_MailSent. Â You can check if this happens correctly, bylooking at the document properties.
Your Save/Close button only needs to contain this :
@command([filesave]);
@command([fileclosewindow]
cheers,
Tom
If I don't comment the fields mentioned previously, the document just saves, it won't run through the entire querysave code. So I don't get my message:
 If (flag%) Then
     Messagebox "The person or persons you selected have been notified"
Without the code I get the message and the email goes out with a doclink. I checked all my previous test and cannot find under the document properties the Req_Mail field.......Which I assume is added after it is sent?!?!? But if it isn't sending then it won't add the field, also I am not getting any of the prompts.
I can send you a copy of the db if you'd like so you can look at it. It's not big at all.

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
      Stop
      Dim LF As String
      Dim doc As notesdocument
      Dim i As Integer
      Dim e1 As String
     Â
      Dim t1 As String
      Dim t2 As String
     Â
      Dim flag As Integer
      Dim SendTo As Variant
      Dim CopyTo As String
      Dim BlindCopyTo As String
      Dim WebSubject As String
      Dim body As String
      Dim wmail As String
     Â
     Â
      Set doc = source.document
     Â
      LF=Chr$(13)+Chr$(10)
      e1 = "Requested:  "+source.document.Req_VMNa
      doc.inheritedsubject = Source.document.subject
      Call source.Refresh
      'If ( source.FieldGetText( "Req_Status" ) = "Complete" )  Then
     Â
     Â
      If source.document.Req_Status
      'If source.document.Status(0) = "Completed" And Not(source.document.hasIte
' send the mail
           t1 = ""
           't2 = Inputbox("Enter Any Pertinent Information for the Requestor", "")
           'If Ltrim$(t2) = "" Then
                 'Exit Sub
           'End If
          Â
          Â
           Sendto = source.document.Req_Notify
           If Isempty(Sendto) Then
                 Exit Sub
           'End If
                 source.document.REQ_MailSe
                Â
           Else
           'Print "not sending mail, request not complete."
                Â
           End If
      End If
      CopyTo = ""
      BlindCopyTo = ""
      WebSubject = "Your VM Ware request is Complete "+doc.inheritedsubject(0)
      body = "Here is a link to the Original Ticket:  "
      wmail = "Double Click this link to access the document -->"
      i = Lbound(sendto)
      For i = Lbound(sendto) To Ubound(sendto)
           flag% = SendMailMemo(sendto(i),Cop
      Next
      If (flag%) Then
           Messagebox "The person or persons you selected have been notified"
      Else
           Messagebox "The mail notification failed to send properly.  "     Â
      End If
     Â
End Sub
i = Lbound(sendto)
For i = Lbound(sendto) To Ubound(sendto)
I tried commenting then out and I get a variant does not contain a container ERROR.
Sub Querysave(Source As Notesuidocument, Continue As Variant)
   Stop
   Dim LF As String
   Dim doc As notesdocument
   Dim i As Integer
   Dim e1 As String
  Â
   Dim t1 As String
   Dim t2 As String
  Â
   Dim flag As Integer
   Dim SendTo As Variant
   Dim CopyTo As String
   Dim BlindCopyTo As String
   Dim WebSubject As String
   Dim body As String
   Dim wmail As String
  Â
  Â
   Set doc = source.document
  Â
   LF=Chr$(13)+Chr$(10)
   e1 = "Requested:  "+source.document.Req_VMNa
   doc.inheritedsubject = Source.document.subject
   Call source.Refresh
   'If ( source.FieldGetText( "Req_Status" ) = "Complete" )  Then
    Â
   If source.document.Req_Status
   'If source.document.Status(0) = "Completed" And Not(source.document.hasIte
' send the mail
     t1 = ""
     't2 = Inputbox("Enter Any Pertinent Information for the Requestor", "")
     'If Ltrim$(t2) = "" Then
        'Exit Sub
     'End If
    Â
    Â
     Sendto = source.document.Req_Notify
     If Isempty(Sendto) Then
        Exit Sub
     End If
     source.document.REQ_MailSe
    Â
 CopyTo = ""
   BlindCopyTo = ""
   WebSubject = "Your VM Ware request is Complete "+doc.inheritedsubject(0)
   body = "Here is a link to the Original Ticket:  "
   wmail = "Double Click this link to access the document -->"
   i = Lbound(sendto)
   For i = Lbound(sendto) To Ubound(sendto)
     flag% = SendMailMemo(sendto(i),Cop
   Next
   If (flag%) Then
     Messagebox "The person or persons you selected have been notified"
   Else
     Messagebox "The mail notification failed to send properly.  "     Â
   End If
   Else
     Print "not sending mail, request not complete."
       Â
    Â
   End If
 Â
  Â
End Sub






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
Lotus IBM
--
Questions
--
Followers
Top Experts
Lotus Software produced the Lotus 1-2-3 spreadsheet program, and later developed Lotus Notes, a groupware and email system. Following its acquisition by IBM, the Notes and Domino client/server collaborative platform were expanded to include functions such as email, calendars, to-do lists, contacts management, teamrooms, discussion forums, file sharing, microblogging, instant messaging, blogs, and user directories. IBM also release SmartSuite, a comprehensive office suite, and followed that with Symphony, unrelated to the Lotus suite of the same name.