Solved

Automated send of form

Posted on 2004-04-07
8
424 Views
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
0
Comment
Question by:jforget1
  • 3
  • 3
  • 2
8 Comments
 
LVL 24

Accepted Solution

by:
HemanthaKumar earned 250 total points
ID: 10777741
Create agent which will be set to run on daily schedule.

Click on Add Search button and select by field and select Start field name and then select Is older than option and set a value of 30. Also add another search to look for specific form and a field flag (flag = "Done") that we will be introducing in the script to say that it has been processed by the agent

The script has to be modified a little bit to support this

     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 col = db.UnprocessedDocuments
     Set doc = col.GetFirstDocument
while not doc is nothing
     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 "
doc.Flag = "Done"
set doc = col.GetNextDocument(doc)
Wend


~Hemanth
0
 

Author Comment

by:jforget1
ID: 10777829
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.
0
 

Author Comment

by:jforget1
ID: 10778194
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.
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10778400
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

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 19

Expert Comment

by:madheeswar
ID: 10780860
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" )
      currentdate=TodayDateTime.lsLocalTime
      
       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
            balancedays=sec/86400
 '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)
      Wend
      
End Sub
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 10780872
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.
0
 

Author Comment

by:jforget1
ID: 10782889
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.  
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 10783407
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.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
I thought it will be a good idea to make a post as it will help in case someone else faces these issues. I trust this gives an idea how each entry in Notes.ini can mean a lot for the Domino Server to be functioning properly. This article discusses t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
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: …

744 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

13 Experts available now in Live!

Get 1:1 Help Now