We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now


Automated send of form

jforget1 asked
Medium Priority
Last Modified: 2013-12-18
Need some help creating an automated mailer based on date. I have the code below to send a basic @mailsend notice but I know it is possible in LS to do the same but have it send a custom form and not just a mailer. I have the code I have used in the past to manually send a form but I want this to go at x number of days out. I guess I want to merge these two methods.
Automated Mailsend
SendTo := "user";
CopyTo := "";
Subject := "Subject";
Remark := "remark";
today:= @Date(@Now);
start:= @Date(date_from);
daysleft:= (start - today)/(60 * 60 * 24);SELECT
@If (daysleft = 30 & Form = "enb survey";@MailSend(sendTo;copyTo;"";Subject ; Remark  ; "" ; [IncludeDoclink]); "")

Manual Send of form
Sub Click(Source As Button)
      Dim workspace As New NotesUIWorkspace          
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
      Dim emaildoc As NotesDocument
      Dim Item As NotesItem
      Dim twoliner As String
      Set db = session.CurrentDatabase
      Set uidoc = workspace.CurrentDocument
      Set doc = uidoc.Document
      Set emaildoc = db.CreateDocument
      emaildoc.form = "enb T-15 Reminder"
      emaildoc.sendto = doc.entered_by(0)
      emaildoc.Subject = "Second Notice - Important Request to complete eNewBusiness Attendance Sheet"
      Call emaildoc.Send(True)
      twoLiner = |T-15 Reminder sent to participant. |
      Messagebox twoLiner, MB_OK, "Send Confirmation "
End Sub
Watch Question

Unlock this solution with a free trial preview.
(No credit card required)
Get Preview


If I wanted the notice to only go on the 30 day mark would I change the search to "is in the next" and then the value of 30. Do I have to put "days" after 30 or does it know because the field in question is a date/time field.


What I need to do is have this form go out when the date is 30 days in the future, but I only want it to go out once, not every day.
If it is future 30 days, then set the search on the date field to "Is after the next"

Also I am stamping the field called Flag = "Done" in the script add this to the search saying Flag , "Does Not Contain" , Done value

If you get into creating the agent all the above will make sense

use the below code:
Sub Initialize
      Dim session As New notessession
      Dim db As notesdatabase
      Dim view As notesview
      Dim doc As notesdocument
      Dim dc As notesdocumentcollection
      Dim TodayDateTime As notesdatetime
      Dim tmpdate As NotesDateTime
      Dim sec As Long
      Dim maildoc As notesdocument
      Dim Body As NotesRichTextItem
      Set tmpdate = New NotesDateTime( "" )
      Set db=session.currentdatabase
      Set view=db.getview("overview") 'Change the view name.
      Set TodayDateTime = New NotesDateTime( "Today" )
       Set doc = view.getfirstdocument
      While Not doc Is Nothing
 'Get values from columns
            tmpname=doc.entered_by(0) 'this holds the Send to names.
            tmpdate.lslocaltime=doc.deadline_d(0) 'ur start date.
 'diffrence between two dates.
            sec = TodayDateTime.TimeDifference( tmpdate )
 'Msgbox sec
 'Msgbox balancedays
 'If the balance is more than one, send mail to interviewer.
            If (balancedays=30) Then ' if it is 30 days then.
 'Msgbox "yes"
                  Set maildoc = New NotesDocument( db )
                  maildoc.Form = "Memo"
                  maildoc.Subject = _
                  "Reminder: Please Review New Application"
                  Set Body=New NotesRichTextItem(maildoc,"Body")
                  message="Please Review the New Application"
                  Call Body.AppendText(message)
                  Call Body.AddNewLine(2)
                  message1="Please Click here to open the Link=========>>"
                  Call Body.AppendText(message1)
                  Call Body.AppendDocLink(doc,"Please Click this Link to open the Document")
                  Call maildoc.Send( True, tmpname )
            End If
            Set doc=view.getnextdocument(doc)
End Sub
Another best example and faster is to create a view and have the selctin formula :
Select form="urForm name" & (@Adjust(startdate;0;0;30;0;0;0)=@Today)

this will collect all the documents which are 30days in future and u can use this view name in the above code. this will be fast and efficient.


So madheeswar would I create a view with the selection formula  above and place that name where you have "overview" in the code. Do these have to work together or was the second comment an alternative solution? Also, in the selection formula wouldn't it be
-@Today and not =@Today, I just don't see where the evaluation is with the equal sign.  
jforget, the selection formula that you are using is the search condition that is specified in the agent. It is easier than maintaining seperate views for this.

Also any view with time/date in selection formula or col will considerably slow down the performance of the db.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.