Link to home
Start Free TrialLog in
Avatar of kali958
kali958Flag for United States of America

asked on

Daily or weekly Email

I have an attendance database that I would like to send a weekly or daily email to mgmt/supervisors to tell them who is out of the office and maybe why.

The reason for the email is the traveilng mgmt and supervisor have blackberry's that have email access but not database access so they would like to know who is out and why while they are on the road.

I have an associate profile doc in the database that tells who each associates supervisor is. I have a view created that is sorted by Date and then employee Name, sup Name, type of time off, and duration. Where i am stuck is how to generate the email to send to the supervisors.

Any help would be much appreciated!!!!
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Why not hourly?? Paranoia kicking in?

Okay, here's a comparable solution:

https://www.experts-exchange.com/questions/21457437/Send-Email-in-Script.html
Avatar of kali958

ASKER

Well with the way it is going, I am surpised it is not hourly :)

I get how to set the lotusscript up for the document, where i am a little lost is that i have a view set up "Sup_Email" The first column is Ascending/Categorized by Date of day off and then the next column is the Supervisor and then column 3 is the employee Name.  The part I am lost on how to do is how do I write it so that the scheduled agent will go out and find todays date, then put the supervisor name as the send to and put the empolyee name in the body.

I am not sure how to insert the data from the view. I can do a @DbLookup in formula language but I have not found how to say it in LS. Basically I want it to just go out and say, okay today is 2/16 and the supervisor is Tom Jones and Carol Smith is out, send him a email to just say that.  

I would ideally like it to be a weekly email but I am not willing to go there right now.

I have only written simple emails in LS that are based on a click. I have an example I am trying to tweak:
Sub Click(Source As Button)
	
	Dim s As NotesSession
	Dim db As NotesDatabase
	Dim ws As NotesUIWorkspace
	Dim uidoc As NotesUIDocument
	Dim doc As NotesDocument
	Dim edoc As NotesDocument
	Dim rtitem As NotesRichTextItem
	Dim Approval As Integer
	
	Set s = New NotesSession
	Set db = s.CurrentDatabase
	Set ws = New NotesUIWorkspace
	
	Set uidoc = ws.CurrentDocument
	Set edoc = New NotesDocument(db)
	Set rtitem = New NotesRichTextItem(edoc, "Body")
	Set doc = uidoc.Document
	'Set uidoc = ws.EditDocument( True )
	uidoc.EditMode = True
 
***I AM ASSUMING HERE IS HERE I WOULD PUT THE GETDOCUMENTBYKEY but I am lost on how to use this
 
	edoc.SendTo = doc.Supervisor(0)
	edoc.Subject = "Associates Out of Office"
	Call rtitem.AppendText("Here is a list of Associate Out of office.")
	Call rtitem.AddNewline(2)
	Call rtitem.AppendText(" ")
	Call rtitem.AddNewline(2)
	Call rtitem.AppendText(" ")
	Call edoc.Send(False)
	
 
	
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

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
Avatar of kali958

ASKER

Okay - I will change the view to be the Supervisor in the first column, Ascending and Catorgized, and then put the date column second and the employeename third.

I will research the NotesViewNavigator and NotesViewEntry method - Thank you. Do I also need to continue w/ researching the GetDocumentByKey?  That is where I seem to be a little lost.

Just to make sure I understand, by changing the view I can have the code then go look at the supervisor name, and if the "Today's" date is in the 2nd column it can then email the supervisor with the employee's name?  I am a bit concerned that this will send an email for each individual associate (so if the sup had two people out, they would get two emails) but then again they asked for a email notification.

I will see how tomorrow goes and let you know.
General idea:

 open the view
 do until eof(view)
      read one line
      if this line contains a new supervisor then
            send assembled mail
            clear mail
      fi
      if there's no mail-document yet then
            create mail-document
      fi
      put info in mail-document
od
if the current mail-document is not sent
      send assembled mail
fi
Avatar of kali958

ASKER

The view right now contains all the time off requests in the database, would it be better if I run the agent daily to then set a status on the form to say "Notification Sent" or it is more coding to have it look at today's date and then send the email?  I was thinking that the key would be the date but I can also change the view to only display today's people that are out of the office and then send the email?
Normally, my scheduled agents always run hourly. If not all code should be executed hourly, I make my own scheduler and logging in a profile document. For instance, I need some code to run nightly, but only once; I put some code in the agent like
      If the daily routine didn't run today Then
            Call daily_routine
            Call update profile document
      End If

A similar thing could be done for your weekly stuff.

The code I add is to make sure the routine isn't executed twice on the same day, e.g. example when an administrator decides to resign all agents or so. I dislike updating documents for no good reason, but if it helps by all means add it. If you need an indicator, you can always use a hidden folder to put your documents in. And if a field should be set in all documents in that folder, you can use StampAll()
Avatar of kali958

ASKER

sjef - I am still working on this issue but a urgent update has come thru that I have to process before i can get back to this issue. Thanks for pointing me in the right direction thou. I will close this question for now and if I need further help I will get something out here.
Thanks for all your help!
You're welcome!!