0
votes

I created a form which consists of a button to send mail notification to the user. I need a scheduled agent to send mail on the user input date. Thank you.

Here is the code for the button:

Sub Click(Source As Button)
    Dim incharge As String
    Dim Session As New NotesSession
    Dim db As NotesDatabase
    Set db = session.CurrentDatabase
    Dim ws As New NotesUIWorkspace
    Dim uidoc As NotesUIDocument
    Dim doc As NotesDocument
    Dim varValues As Variant
    Dim varCC As Variant

    Set uidoc = ws.currentDocument
    Set doc = uidoc.Document
    varCC = "(the CC address)"
    varValues = doc.GetItemValue( "incharge" )
    Dim email As NotesDocument
    Set email = db.CreateDocument
    email.Form="project"
    email.Principal="(the sender address)"
    email.Subject="(subject)"
    email.CopyTo=  varCC
    If Not Isnull( Arraygetindex( varValues, "Employee 1" ) ) Then
    email.Body = "Message"
    email.SendTo = "Employee 1 Address"
    Call email.Send(False)
    Else
    End If
    If Not Isnull( Arraygetindex( varValues, "Employee 2" ) ) Then
        email.Body = "Message"
        email.SendTo = "Employee 2 Address"
        Call email.Send(False)
    Else
    End If
    If Not Isnull( Arraygetindex( varValues, "Employee 3" ) ) Then
        email.Body = "Message"
        email.SendTo = "Employee 3 Address"
        Call email.Send(False)
    Else
    End If
    If Not Isnull( Arraygetindex( varValues, "Employee 4" ) ) Then
        email.Body = "Message"
        email.SendTo = "Employee 4 Address"
        Call email.Send(False)
    Else
    End If
    If Not Isnull( Arraygetindex( varValues, "Employee 5" ) ) Then
        email.Body = "Message"
        email.SendTo = "Employee 5 Address"
        Call email.Send(False)
    Else
    End If
    If Not Isnull( Arraygetindex( varValues, "Employee 6" ) ) Then
        email.Body = "Message"
        email.SendTo = "Employee 6 Address"
        Call email.Send(False)
    Else
    End If
End Sub

This code sends the mail once the button is clicked. Thank you!

1
Jamie, welcome to Stack Overflow. What have you tried already? See stackoverflow.com/help/how-to-ask.Per Henrik Lausten

1 Answers

1
votes

When the button is clicked, just save the document. Then create a scheduled agent that runs once per day, and do a db.search() looking for "project" documents with the current date, iterate through the collection and send them.

That's one way, there are many others.