Solved

Wrong Email Notification is going from agent

Posted on 2011-02-21
17
979 Views
Last Modified: 2013-12-18
There's is an email notification which works on notification date set.
There are two fields notifiy date and due date.
Email should go if the current date is between notifiy date and due date

user created an action on 18/02/2011.
The Due Date is set as 10/03/2011.
The Notification Date is set as 25/02/2011 and the Delay Notice is set as "weekly" so user would expect to receive the first notification on 25/02/2011.

User started receiving the notification today 19/02/2011 (the next day the action has been created)

Please find the below code for mail sending :

Set duedate=New NotesDateTime(doc.Getitemvalue("act_DueDate")(0))
Set notifydate=New NotesDateTime(doc.Getitemvalue("act_Notify")(0))
stat=doc.Getitemvalue("act_status")(0)
resp=doc.getItemValue("act_responsible")
copy=doc.getItemValue("act_ccPeople")
bodystr="delay notice 1"      
bodystr1="delay notice2"            
      If (stat="") Then
      
        If (currentdate.Dateonly() >=notifydate.Dateonly())And (currentdate.Dateonly() <=duedate.Dateonly())Then
           ' Call mailsend(doc,db,resp,copy,bodystr)
       End If
      If (currentdate.Dateonly()> duedate.Dateonly())Then
          'Call mailsend(doc,db,resp,copy,bodystr1)
      End If
0
Comment
Question by:Glactus
  • 9
  • 5
  • 3
17 Comments
 
LVL 22

Expert Comment

by:mbonaci
ID: 34942121
You can use the code from this recent, similar post:

http://www.experts-exchange.com/Q_26801021.html
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34942215
So, to check whether the date falls between two dates:

Can you post the actual code, since both MailSend calls are commented out.
'if Notification date is older (smaller) than Our date
'and Our date is older (smaller) than Due date

Dim dueDate As New NotesDateTime(doc.Getitemvalue("act_DueDate")(0))
Dim notifyDate As New NotesDateTime(doc.Getitemvalue("act_Notify")(0))
Dim currentDate As New NotesDateTime(Today)

If notifyDate.TimeDifference(currentDate) > 0 And currentDate.TimeDifference(dueDate) > 0 Then
    '... send mail...
End If

Open in new window

0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34942264
Sorry, wrong code:
'if Today is bigger than Notification date (notification date passed)
'and Today is smaller than Due date (Due date still has to come)

Dim dueDate As New NotesDateTime(doc.Getitemvalue("act_DueDate")(0))
Dim notifyDate As New NotesDateTime(doc.Getitemvalue("act_Notify")(0))
Dim currentDate As New NotesDateTime(Today)

If currentDate.TimeDifference(notifyDate) > 0 And currentDate.TimeDifference(dueDate) < 0 Then
    '... send mail...
End If

Open in new window

0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34942273
It sounds little odd that you don't want to send mail if both Notification and Due date have passed?
I mean, shouldn't you have to check only doc state and Notification date, and if state is empty and Notification date has passed - send mail?
0
 

Author Comment

by:Glactus
ID: 34942377
 If (currentdate.Dateonly()> duedate.Dateonly())Then
          'Call mailsend(doc,db,resp,copy,bodystr1)

this is sending mail if the current date is greater then duedate .
The mail body is different in this case.

The code i have mentoned in the above post is working fine from 1 year .
Its giving problem for one particular document .

I have copied that particular document in the test copy of the database.
I debuged the agent and its working fine .

But in production server its giving trouble.

Can you please tell me why it is behaving like this .?
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 34942395
1. I'd code this differently:

      If currentdate.Dateonly()> duedate.Dateonly() Then
          'Call mailsend(doc,db,resp,copy,bodystr1)
      ElseIf currentdate.Dateonly() >=notifydate.Dateonly() Then
           ' Call mailsend(doc,db,resp,copy,bodystr)
      End If

2. Are your dates Strings? Is "10/2/2011" converted to February 10th or October 2nd ? Can you run your code in the debugger?
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34942396
Have you examined the date fields on that document?
Go to document properties > second tab > select date field > does it say the type is Time/Date in the right window?

Have you tried to simply open that document, save and close it, to refresh items with actual form fields?
0
 

Author Comment

by:Glactus
ID: 34949023
@sjef_bosman

both duedate and notifydate are notesdate time .
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:mbonaci
ID: 34949488
Can you answer my questions?
0
 

Author Comment

by:Glactus
ID: 34950929
Yes mbonaci

Now the user is telling that he is getting this issue for all the documents .

I did what you suggested but the problem is still there .

both duedate and notifydate are notesdate time

As i have debugged the agent and  the agent is working fine for me.There are no issues in the test enviornment.

but it is giving trouble in production server.

0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34951325
One silly question, since test environment is working fine, have you checked the production server date?
You haven't posted the actual code.
Post the entire agent's code.
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 34951456
The server's date string conversion may differ from the user's. Usually, servers display American date/time strings. Maybe that's where your problem lies...
0
 

Author Comment

by:Glactus
ID: 34957654
Use "SendReminderMail"

Sub Initialize()
  On Error GoTo ErrorHandler
      Dim ns As New NotesSession
      Dim db As NotesDatabase
      Dim View As NotesView
      Dim doc As NotesDocument
      Dim vcReq As NotesViewEntryCollection
      Dim entry As NotesViewEntry
      Dim docMail As NotesDocument
      Dim returnVar As Variant
      Dim SendTo,CopyTo As Variant
      Dim Subject As String
      Dim rbody As String
      Dim duedate As NotesDateTime
      Dim notifydate As NotesDateTime
      Dim currentdate As New NotesDateTime(now)
      Dim stat As String
      Dim resp,copy As variant
      Set db             =       ns.CurrentDatabase
      Set View       =       db.GetView("Notification")
      Dim bodystr As string
      Dim bodystr1 As String
      Set doc =view.Getfirstdocument()
      
      
      While Not doc Is Nothing
      Set duedate=New NotesDateTime(doc.Getitemvalue("act_DueDate")(0))
      Set notifydate=New NotesDateTime(doc.Getitemvalue("act_Notify")(0))
      stat=doc.Getitemvalue("act_status")(0)
      resp=doc.getItemValue("act_responsible")
      copy=doc.getItemValue("act_ccPeople")
      bodystr=" body1111"      
      
    bodystr1="body 2222"      
      If (stat="") Then
      
        If (currentdate.Dateonly() >=notifydate.Dateonly())And (currentdate.Dateonly() <=duedate.Dateonly())Then
            Call mailsend(doc,db,resp,copy,bodystr)
       End If
      If (currentdate.Dateonly()> duedate.Dateonly())Then
          Call mailsend(doc,db,resp,copy,bodystr1)
      End If
      
      End If
            Set doc=view.Getnextdocument(Doc)
            
            Wend
      Exit Sub
      
      ErrorHandler:      
      MessageBox CStr(Err)+"-" +Error(Err) + " at line " + CStr(Erl)
      Exit Sub
      
      End Sub
0
 

Author Comment

by:Glactus
ID: 34958456
@all

i have debugged again nd found the logic is wrong .

I set due date to 10march2011

If (currentdate.Dateonly()> duedate.Dateonly())Then
          Call mailsend(doc,db,resp,copy,bodystr1)
  End If

it is satisfying the above condition thats wy it is sending mails.

0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 34958739
But of course: DateOnly is a String.

Try with

If currentdate.LSLocalTime> duedate.LSLocalTime Then
          Call mailsend(doc,db,resp,copy,bodystr1)
End If
0
 
LVL 22

Expert Comment

by:mbonaci
ID: 34958882
I posted the correct logic in my previous question, here: #34942264
0
 
LVL 22

Accepted Solution

by:
mbonaci earned 125 total points
ID: 34958897
I meant to say, my previous post, here.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

22 Experts available now in Live!

Get 1:1 Help Now