Solved

Wrong Email Notification is going from agent

Posted on 2011-02-21
17
990 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

688 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