I am using below code to add an appointment to the recipients calendar.
It works fine for India users. But when users from other timezone add the appointment it is not getting converted to local time.
Can any one help ?
Code below
Sub Click(Source As Button)
Dim session As New notessession
Dim workspace As New notesuiworkspace
Dim uidoc As NotesUIDocument
Dim mailDoc As notesdocument
Dim mailDB As NotesDatabase
Dim strDate As String
Dim strLocation As String
Dim strStartTime As String
Dim strEndTime As String
Dim userName As New NotesName(session.UserName)
Set uidoc=workspace.CurrentDocument
Set doc=uidoc.document
'**********Please modify this section before sending********
strTitle="Test"
strDate="11SEPTEMBER2014"
strLocation="BLR"
strStartTime="10:05"
strEndTime="10:20"
'************************************************************************
Set mailDB=session.CurrentDatabase
Set mailDoc=mailDB.CreateDocument
Set startTime=New NotesDateTime(strDate & " - " & strStartTime & " IST")
Set endTime=New NotesDateTime(strDate & " - " & strEndTime & " IST")
mailDoc.StartTimeZone="Z=-3005$DO=0$ZX=35$ZN=India"
mailDoc.EndTimeZone="Z=-3005$DO=0$ZX=35$ZN=India"
mailDoc.Form="Appointment"
mailDoc.AppointmentType="0"
mailDoc.Location=strLocation
mailDoc.Subject=strTitle
mailDoc.Principal=userName.Common
Dim currItem As NotesItem
Set currItem=mailDoc.AppendItemValue("StartDate", startTime)
Set currItem=mailDoc.AppendItemValue("StartDate", startTime)
Set currItem=mailDoc.AppendItemValue("EndDate", endTime)
Set currItem=mailDoc.AppendItemValue("StartTime", startTime)
Set currItem=mailDoc.AppendItemValue("EndTime", endTime)
Set currItem=mailDoc.AppendItemValue("StartDateTime", startTime)
Set currItem=mailDoc.AppendItemValue("EndDateTime", endTime)
Set currItem=mailDoc.AppendItemValue("CalendarDateTime", startTime)
'*********Popup for the Alarm***************
Call mailDoc.ReplaceItemValue("Alarms","1")
Call mailDoc.replaceitemvalue("$Alarm",1)
Call mailDoc.replaceitemvalue("$AlarmOffset",-120)
Call mailDoc.ReplaceItemValue("$AlarmUnit", "M")
Call mailDoc.ReplaceItemValue("$IconSwitcher", |Reminder|)
Call mailDoc.ReplaceItemValue("$AlarmMemoOptions", "")
Call mailDoc.ReplaceItemValue("dispAlarms","1")
Call mailDoc.ReplaceItemValue("dispAlarmsRd","1")
Call mailDoc.ReplaceItemValue("HideFromCalendar", "1")
'******************************End popup********
Call mailDoc.ReplaceItemValue("_ViewIcon",158)
Set currItem=doc.GetFirstItem("Body")
Call currItem.CopyItemToDocument(mailDoc,"Body")
Call mailDoc.ReplaceItemValue("SequenceNum","1")
Call mailDoc.ReplaceItemValue("$CSVersion",|2|)
Call mailDoc.ComputeWithForm(True, True)
Call mailDoc.Save(True, False)
On Error Resume Next
Set uidoc= workspace.EditDocument(True,mailDoc)
Set csEventObj= New CSCalendarEntry( 1, mailDoc, uidoc )
Call csEventObj.SetUIFlag( UI_FLAG_ALARM )
Call csEventObj.QueryClose( Continue)
Call csEventObj.QuerySave( True)
Call csEventObj.PostSave()
On Error Goto 0
''Call uidoc.Close(True)
''Dim var
''var=Messagebox("Calendar Entry added.", 0, "Mail Db")
End Sub
If you look at a meeting created manually, you'll see that StartDateTime contains a date and time, but StartDate contains just the date, and StartTime contains just the time. That's not how you've done it here, and I suspect that's your problem.
Also, use ReplaceItemValue, not AppendItemValue, to set a field. And I see you set the same field more than once (which, since you were using the wrong method, made it multivalued).
Related
Question:
1. My question why after registration of an user still not listed in domino directory?
Case:
I am using xPages form call lotus script agent.
All my script is using lotus script to register an user.
After Complete register an email, need to send automation notification mail to user as welcome mail.
when i complete registration, i want to send mail, it give me an error message:
1.unable to deliver message 'ChunWH#devsvr1.pcs.com.my'
2.User 'ChunWH#devsvr1.pcs.com.my' not listed in Domino Directory
Register user Agent
Option Public
Option Declare
Sub Initialize
On Error GoTo ErrorHandler
Dim s As New NotesSession, db As NotesDatabase, a As NotesAgent
Dim doc As NotesDocument
Set db = s.Currentdatabase
Set a = s.Currentagent
Set doc = s.Documentcontext ' uidoc
Dim maildoc As NotesDocument, body As NotesMIMEEntity
Dim stream As NotesStream
Dim groups
groups = Null
groups = group(groups,"Everyone")
Dim certid As String ' full path of cert id
Dim certpasswd As String
Dim OU As String
Dim lastname As String
Dim firstname As String
Dim middleinit As String
Dim usrIdpath As String
Dim mailsvr As String
Dim mailfile As String
Dim userpasswd As String
Dim internetpathLength As String
Dim internetpath As String
Dim remapuserID As String
Dim depvw As NotesView, depdoc As NotesDocument
Set depvw = db.Getview("Department sort by dept")
Set depdoc = depvw.Getdocumentbykey(doc.Dept(0), True)
If Not depdoc Is Nothing Then
certid = depdoc.IdPath(0)
certpasswd = depdoc.IdPassword(0)
OU = ""
lastname= doc.Name(0)
firstname = ""
middleinit = ""
usrIdpath = depdoc.DptIdStor(0) +doc.SelectMail(0)+ ".id"
' remove "." replace with empty and remove the empty space
remapuserID = remapChr(doc.SelectMail(0)) ' this is remapuserID
mailsvr = depdoc.MailSvr(0) ' mail svr
' Mail file name also cannot have . in between for example, mail/test1.apple, reason window not understand it
mailfile = depdoc.MailLocation(0)+ remapuserID ' Mail\Person
userpasswd= depdoc.UserPassword(0)
internetpath = doc.SelectMail(0)+depdoc.InternetPath(0) ' mail address
internetpathLength = Len(depdoc.InternetPath(0)) ' not used
End If
Dim reg As New NotesRegistration
Dim dt As Variant
dt = DateNumber(Year(Today)+1, Month(Today), Day(Today))
reg.RegistrationServer = mailsvr
reg.CreateMailDb = True '
reg.CertifierIDFile = certid
reg.Expiration = dt
reg.IDType = ID_HIERARCHICAL
reg.MinPasswordLength = 1
reg.IsNorthAmerican = True
reg.OrgUnit = OU
reg.RegistrationLog = "log.nsf"
reg.UpdateAddressBook = True
reg.Storeidinaddressbook = false
reg.MailInternetAddress = internetpath
reg.Shortname=doc.SelectMail(0)
reg.Mailowneraccess =2
reg.Mailcreateftindex=True
reg.Mailaclmanager ="LocalDomainAdmins"
reg.Grouplist=groups
Call reg.RegisterNewUser(lastname, _
usridpath, _
mailsvr, _
firstname, _
middleInit, _
certpasswd, _
"", _
"", _
mailfile, _
"", _
userpasswd, _
NOTES_DESKTOP_CLIENT)
Dim acl As NotesACL
Dim aclEntry As NotesACLEntry
Dim dbUser As NotesDatabase
Set dbUser = New NotesDatabase(mailsvr,mailfile) ' mail/person.nsf
Set acl = dbUser.aCL
Set aclEntry = acl.Getentry( "LocalDomainAdmins" )
If Not (aclEntry Is Nothing) Then
aclEntry.UserType = ACLTYPE_PERSON_GROUP
Call acl.Save()
End if
' call name nsf and open for edit for forcing user must change password first time
Dim ndb As NotesDatabase
Dim viwUser As NotesView
Dim docUser As NotesDocument
Set ndb = New NotesDatabase( mailsvr, "names.nsf" )
Set viwUser = ndb.GetView("People by Email")
Set docUser = viwUser.GetDocumentByKey(doc.SelectMail(0),True)
Call docUser.ReplaceItemValue( "HTTPPasswordForceChange" , "1" )
Print "Force user change password is updated"
Call docUser.Save( True, True, True )
Print "Please wait ...... Registration in progress"
Call doc.Replaceitemvalue("S_Process", "Pending")
Call doc.Save(True, False)
Dim agt As NotesAgent
Set agt=db.getagent("(Welcome Mail)")
Call agt.Runonserver()
EndOfRoutine:
Exit Sub 'or exit function
ErrorHandler:
Print Err & ", " & Error & " in line " & Erl
Resume EndOfRoutine
End Sub
Function remapChr (oldString)
' to replace all special character with a empty space after that trim to remove all special character in system
Dim oldChr, newChr, newString As String
oldChr = {! "" # $ % & ' ( ) * + , - . / : ; = > ? # [ \ ] ^ _}
newChr = " {"
oldChr = Split(oldChr, " ")
newChr = Split(newChr, " ")
newString = Trim(Replace(LCase(oldString), oldChr, newChr))
remapChr = newString
End Function
Function group(groupArr, newReason$)
If IsArray(groupArr) Then
If groupArr(0) = "" Then
groupArr(0) = newReason
Else
Dim counter%
counter = UBound(groupArr) + 1
ReDim Preserve groupArr(counter)
groupArr(counter) = newReason
End If
group = groupArr
Else
Dim tempgroupArr() As String
ReDim tempgroupArr(0)
tempgroupArr(0) = newReason
group = tempgroupArr
End If
End Function
Sending mail Agent
Sub Initialize
On Error GoTo ErrorHandler
Print "Welcome Mail Agent started..."
' This agent is a sub agent for register user, which let register agent call
Dim s As New NotesSession, db As NotesDatabase, a As NotesAgent
Dim doc As NotesDocument
Set db = s.Currentdatabase
Set a = s.Currentagent
Set doc = s.Documentcontext ' uidoc
Dim maildoc As NotesDocument, body As NotesMIMEEntity
Dim stream As NotesStream
Dim receiver$
Dim tmpallve As NotesViewEntry
Dim viwUser As NotesView
Dim viwVe As NotesViewEntry
Dim viwVc As NotesViewEntryCollection
Dim docUser As NotesDocument
Set viwUser = db.GetView("(Request sort by S_Process)")
'Set docUser = viwUser.GetDocumentByKey("Pending",True)
Set viwVc = viwUser.Allentries
If viwVc.Count = 0 Then
Print "No item found in this list"
Exit Sub
End If
Set viwVe = viwVc.Getfirstentry()
Do While Not viwVe Is Nothing ' loop to all entry
Set docUser = viwVe.Document
receiver$ = docUser.SelectMail(0) + "#devsvr1.pcs.com.my"
' send mail
Set maildoc = db.Createdocument()
Call maildoc.Replaceitemvalue("Form", "Memo")
Call maildoc.Replaceitemvalue("Subject", "Welcome")
Call maildoc.Replaceitemvalue("SendTo", receiver)
Set body = maildoc.Createmimeentity
s.Convertmime = False
Set stream = s.Createstream()
stream.Writetext(|<html><body>|)
stream.Writetext(|<p>Your application for registration ....</p>|)
stream.Writetext(|<p>Welcome. Pleaase....</p>|)
stream.Writetext(|<p><em>(No signature requried on this computer generated document)</em></p>|)
stream.Writetext(|<p>*** This is a system generated email. | + _
|Please do not reply to this email. ***</p>|)
Call stream.Writetext(|</body></html>|)
Call body.Setcontentfromtext(stream, "text/html;charset=UTF-8", 1725)
Call maildoc.Send(False)
s.Convertmime = True
Call docUser.Replaceitemvalue("S_Process", "Processed")
Call docUser.Save(True, False)
Set tmpallve = viwVc.Getnextentry(viwVe)
Set viwVe = tmpallve
Loop
Print "Welcome Mail Agent finished..."
EndOfRoutine:
Exit Sub 'or exit function
ErrorHandler:
Print Err & ", " & Error & " in line " & Erl
Resume EndOfRoutine
End Sub
new update of image on 25/09/2017
(after set config router_debug=3 set config DebugRouterLookup=3 )
i try send manually will be fine...but using code directly send after registration will be fail. Not only that, i also try on sleep(2) , wait 2 second just send mail..it seem like my thought of not directly create mail account mail also not valid..not sure which part is wrong?
I suspect that your issue is one of time and caching. The Domino server maintains a Name Lookup Cache that only gets refreshed, well, occasionally (I have never figured out how occasionally that is but 5-10 minutes generally does the trick). This affects both the email functions and the web login functions. What I have done with my registration systems is have the agent that does the ID creation leave a document in it database that is in the status "Pending welcome email". Then another agent finds those docs and if they are more then 15 minutes old it attempts the email. if the email goes through then the status is changed to "Complete".
Note, you can reset the cache with the console command show nlcache reset and that almost always results in the user being able to get mail and login from a browser. But I have not been able to get that to work from a scheduled agent run on the server or a web agent.
Can you take a look at the Person Document? See if that address is properly registered on the document.
You may also try to enable router_debug=3 and DebugRouterLookUp=3 and we may see where did it try to lookup the address.
I'm new with Notes and LotusScript and I got a problem.
I need to create a table in a rich text item, I have used an "action partagée" (maybe "shared action" in English). My code runs without returning an error but my table is not visible.
Sub Click(Source As Button)
On Error Goto errorhandler
Dim workspace As New NotesUIWorkspace
Dim session As New NotesSession
Dim db As NotesDatabase
Dim uidoc As Notesuidocument
Dim doc_bdl As NotesDocument
Dim table As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
' création du document
Set uidoc = workspace.ComposeDocument("","","EXPEDITION")
Set doc_bdl = uidoc.Document
Set table = New NotesRichTextItem(doc_bdl,"rtTableau")
' création du tableau
Call table.AppendTable(4, 3)
Set rtnav = table.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_TABLECELL)
Dim iRow As Integer
Dim iColumn As Integer
For iRow = 1 To 4 Step 1
For iColumn = 1 To 3 Step 1
Call table.BeginInsert(rtnav)
Call table.AppendText("Ligne " & iRow & ", Colonne " & iColumn)
Call table.EndInsert
Call rtnav.FindNextElement(RTELEM_TYPE_TABLECELL)
Next
Next
Exit Sub
errorHandler:
Print Lsi_info(2) & " : " & Err & " (" & Error & ") ligne " & Erl
Exit Sub
End Sub
I have read that to see the content of rich text items it's necessary to refresh the document. So I used examples in the help.
I tried to add this :
Call doc_bdl.Save(True, False)
Dim ws As New NotesUIWorkspace
Call ws.ViewRefresh
I got no error but I still not see my table.
I tried this :
Call doc_bdl.Save(True, False)
Call doc_bdl.Refresh(True)
I got this error : "Illegal use of PROPERTY"
Can someone help me ? Thank you in advance
PS : English is not my language so please excuse my possible errors, I don't find french forums for help.
You need to do something like this:
' Save your backend document with the updated RichText field
Call doc_bdl.Save(True, False)
' Open saved backend document as a uidoc
ws.EditDocument(True, doc_bdl)
If you want to build a table with content, and you don't know how many rows there will be (and/or if you want more control ov the formatting of the table) you can use this technique:
http://blog.texasswede.com/dynamic-tables-in-classic-notes/
Problem :
Using Agent run and send mail give a different link
Mail Contain a link which is not include database
I set it send to a yahoo mail
Sub Initialize()
Print"Agent:First Reminder for LateIn Reason started running at " & DateValue(Now()) & "," + TimeValue(Now())
Dim ss As New NotesSession
Dim db As NotesDatabase
Dim LateInVw As NotesView
Dim LateInDocs As NotesViewEntryCollection
Dim LateEntry As NotesViewEntry
Dim LateDoc As NotesDocument
Dim StaffVw As NotesView, StaffDoc As NotesDocument
Dim MailDoc As NotesDocument
Dim rtBody As NotesRichTextItem
Dim sysdoc As NotesDocument, sysVw As NotesView
Dim AttVw As NotesView, Attdoc As NotesDocument
Set db=ss.Currentdatabase
Set sysVw=db.getview("($System Settings)")
Set sysdoc=sysvw.getfirstdocument
If sysdoc Is Nothing Then Exit Sub
Set LateInVw=db.getview("(Testing Late-In Time Records)")
Set StaffVw=db.getview("($Active Staff by ID)")
Set AttVw = db.Getview("($Effective Attendance Setting By ID)")
tdy=Datevalue(Now)
'get all time records for today
Set LateInDocs=LateInVw.Allentries
Set lateEntry=LateInDocs.getfirstentry
Do While Not LateEntry Is Nothing
Set LateDoc=LateEntry.Document
Set Attdoc=Attvw.Getdocumentbykey(LateDoc.TStaffID(0), True)
If Attdoc.LateAtt(0)="Yes" Then
If LateDoc.LateReason(0)="" Then
If Not ApprovedLateIn(LateDoc, LateDoc.TAmend(0), False) Then
'get staff mail
Set staffDoc=StaffVw.Getdocumentbykey(LateDoc.TStaffID(0), True)
If Not staffdoc Is Nothing Then
'send email with link to main menu
If email$<>staffDoc.email(0) Then
' email$=staffDoc.email(0)
email$="chee111385#gmail.com"
Set Maildoc=New NotesDocument(db)
Set maildoc=db.Createdocument()
maildoc.Form="First Reminder Notification"
maildoc.Subject="Smartcard Attendance System: Late-In Notification for " +Format$(LateDoc.TDate(0),"dd/mm/yyyy")
Maildoc.StaffName=staffDoc.StaffName(0)
maildoc.Sendto="chee111385#gmail.com"
' maildoc.NotifyDate=LateDoc.Tdate(0)
maildoc.NotifyTime=Timevalue(LateDoc.TAmend(0))
maildoc.NotesServer=sysdoc.ServerPath(0)
maildoc.NotesDBPath=sysdoc.DBPath(0)
maildoc.send(True)
End If
End If
End If 'check against unimas's jadual kedatangan
End If 'check for late in reason
End If 'check late-in on/off in attendance settings
Set LateEntry=LateInDocs.Getnextentry(LateEntry)
Loop
End Sub
I will attach my image file and coding here
from this 2 image you can see that, actually i want to put as a
notes://Mulu/SmartCard Attedancce/sas-server.nsf/Scais Main?OpenFrameset
but result of the mail send out is
notes:////Scais Main?OpenFrameset
which is no server and database. I am not sure what part of my coding is wrong
Another attachment will be the form i use as mail.form
First of all: Sending an external mail with a custom form like you do it is not the best Idea, as the target system might not be able to render everything accordingly.
That said, I would first create a document that contains all data and then RENDER it to a maildoc. code would look like this:
Dim Templatedoc as NotesDocument
Dim body as NotesRichtextItem
Set Templatedoc=New NotesDocument(db)
Set Templatedoc=db.Createdocument()
Templatedoc.Form="First Reminder Notification"
Templatedoc.StaffName=staffDoc.StaffName(0)
' maildoc.NotifyDate=LateDoc.Tdate(0)
Templatedoc.NotifyTime=Timevalue(LateDoc.TAmend(0))
Templatedoc.NotesServer=sysdoc.ServerPath(0)
Templatedoc.NotesDBPath=sysdoc.DBPath(0)
Set maildoc=New NotesDocument(db)
maildoc.Form = "Memo"
maildoc.Subject="Smartcard Attendance System: Late-In Notification for " +Format$(LateDoc.TDate(0),"dd/mm/yyyy")
maildoc.Sendto="chee111385#gmail.com"
Set body = New NotesRichtextItem( maildoc, "Body" )
Call Templatedoc.RenderToRTItem( body )
maildoc.send(True)
Second: You set two fields (NotesServer and NotesDBPath) to compute your Link. But your link in reality is computed from environment- variables, and these are not set on the server.
Change your Link- Computation- Formula to:
srv := NotesServer;
pth := NotesDBPath;
That should do the trick for the link.
I'm getting the error message below:
Upon clicking the doclink which was being attached in the e-mail which was generated by me through clicking the send to managers button. I also tried using NotesURL instead of doclink:
Call rtitem.appendtext(emaildoc.Notesurl)
but the generated URL is different from the doclink. Below is the generated from the doclink itself.
Generated NotesURL: notes://LNCDC#PHGDC/__48257E3E00234910.nsf/0/237B2549EEA393A948257E530042BA4A?OpenDocument
Doclink: Notes://LNCDC/48257E3E00234910/28BD6697AB48F55348257E2D0006CF60/C9B0266FDC0D929E48257E530041D6F9
Can you please help? Below is my agent code.
%REM
Agent Send Email to Managers
%END REM
Option Public
Option Declare
Dim s As NotesSession
Dim db As NotesDatabase
Dim emaildoc As NotesDocument
Dim paydoc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim i As Integer
Dim view As NotesView
Sub Initialize
Set s = New NotesSession
Set db = s.CurrentDatabase
Set view = db.GetView("Pending Claims")
Dim addresses As NotesName
Dim arrpem As Variant
ReDim arrpem(0)
Set paydoc = view.GetFirstDocument
'// Store all PEM names in an array
While Not(paydoc Is Nothing)
ReDim Preserve arrpem(UBound(arrpem) + 1)
arrpem(UBound(arrpem)) = paydoc.PeopleManager(0)
Set paydoc = view.GetNextDocument(paydoc)
Wend
'// Remove all duplicate PEM names and empty entries in the array
arrpem = FullTrim(ArrayUnique (arrpem))
'// Loop the PEM names array
ForAll pem In arrpem
Set emaildoc = New NotesDocument(db)
Set addresses = New NotesName(pem)
If addresses.abbreviated <> "" Then
emaildoc.SendTo = addresses.abbreviated
emaildoc.Subject = "Leave Balances of your Direct Reports"
emaildoc.Form = "Memo"
Set rtitem = New NotesRichTextItem(emaildoc, "Body")
Call rtitem.AppendText("Dear " & addresses.common & ",")
Call rtitem.AddNewLine(2)
'// Remove paydoc value which was used in the PEM names array
Set paydoc = Nothing
'// Get all documents that has matching PEM name in the view
Dim dc As NotesDocumentCollection
Set dc = view.GetAllDocumentsByKey(addresses.Abbreviated, True)
Set paydoc = dc.GetFirstDocument
'// Append doc link of employee
While Not(paydoc Is Nothing)
Call rtitem.AppendText("Doc link of :" & paydoc.FMName(0) & " " & paydoc.LastName(0))
Call rtitem.appenddoclink(emaildoc, "Link to Leave Balance of " & paydoc.FMName(0) & " " & paydoc.LastName(0))
Call rtitem.AddNewLine(1)
Set paydoc = dc.GetNextDocument(paydoc)
Wend
'// Send email per PEM
Call emaildoc.Send(False)
End If
End ForAll
MsgBox "Emails successfully sent."
End Sub
The doclink is pointing back to the document you've created in memory for your email. When sent, that document no longer exists in the original database.
Change your code to be:
Call rtitem.appendtext(paydoc.Notesurl)
I have form with 3 fields adress,status,ReportingDate.
Adress field contains the ID where the mil has to be sent.
Now I have created an agent where it should mail to the data present in adress field when status is incomplete and reporting date is exactly 7 days before todays date.
My Code:
Option Public
Option Declare
Sub Initialize
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim timestamp As New NotesDateTime("Today")
Dim Noresponsedate As NotesDateTime
Dim vw As NotesView
Dim diff As Integer
Dim SendTo As Variant
Call timestamp.SetNow()
Set db = sess.CurrentDatabase
Set vw = db.GetView( "data" )
Set doc = vw.GetFirstDocument()
While Not doc Is Nothing
If doc.Status(0) = "Incomplete" Then
Call checktimedifference(doc)
End if
Set doc = vw.GetNextDocument(doc)
wend
End Sub
Sub checktimedifference(doc As NotesDocument)
Dim due As NotesDateTime
Dim present As NotesDateTime
Dim timecheck As variant
Set due = New NotesDateTime ( "" )
Set present = New NotesDateTime ( "Today" )
timecheck = doc.ReportingDate(0)
due.LSLocalTime = timecheck
If due.TimeDifference (present) = -604800 Then
Call sendmailtouser(doc)
End If
End Sub
Sub sendmailtouser(doc As NotesDocument)
Dim db As NotesDatabase
Dim rtiitem As NotesRichTextItem
Dim maildoc As NotesDocument
dim recepient As variant
Set maildoc = New NotesDocument( db )
Set rtiitem = New NotesRichTextItem( maildoc, "Body" )
recepient = doc.adress(0)
maildoc.from = db.Title
maildoc.form = "memo"
maildoc.subject = "A Minor Injury Report:" & doc.Seq_No(0) & " needs your response"
maildoc.SendTo = recepient
Call rtiitem.AppendText( "Please respond to this Minor Injury Report" )
Call rtiitem.AddNewline( 2 )
Call rtiitem.AppendText( "Your response for the Minor Injury Report: " & doc.Seq_No(0) & " is required" )
Call rtiitem.AddNewline( 2 )
Call rtiitem.AppendText( "Please click on the following link to access the document.")
Call rtiitem.AppendDocLink( doc, db.Title )
Call maildoc.Send(False)
End Sub
When I am running the agent on client I am getting the following error:
Please help me to solve the error and send mail to the recepients.
Not using any error handling is very bad practice. But your error will most probably happen in the sendmailtouser- sub, where you dim a local notesdatabase- object named db without actually initializing it.
The line
set maildoc = New NotesDocument( db )
will fail.
Either declare db globally and set it in your initialize or dim ses in that sub again and set db again (worst case as you have to do it for every document)