All,
I have the following code in a button click that based on a number on the form in database A,
Selects a view and a document in database B.
I have this working fine. If I do a: Call w.EditDocument(True, doc) then the correct document will open up in database B.
However, I don’t want to open the document, instead I want to run an agent in that database which will send mail.
The agent to create the mail is set to: Agent List Selection, with a Target of None, the name of the code is (CSRMailSendLS)
That code looks like this (“Body” field is a RT with a table in it):
FIELD PubTDS:= PubTDS;
@MailSend(PubTDS;“Teri Colvin”;“”;"This is a test mail from the Pub button, new MDP form for: " + TechRel_1 + ECRNumLkup;"Please review the Literature for this project: " + TechRel_1 + ECRNumLkup ;“Body”);
@All
The code that calls the above code:
Dim session As New NotesSession
Dim workspace As New NotesUIWorkspace
Dim db As NotesDatabase
Dim db2 As NotesDatabase
Dim doc As NotesDocument
Dim view As NotesView
Dim key As String
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
key = uidoc.FieldGetText( "Prefix") + uidoc.FieldGetText( "ECRNum")
Set db2 = session.GetDatabase("Edison/SEL","MfgDevPlan.nsf")
Set view = db2.GetView( "(MDPPubLkup)" )
Set doc = view.GetDocumentByKey(key , True )
Dim ECRNumLkup As NotesItem
Dim agent As NotesAgent
If doc Is Nothing Then 'check is there an MDP in the database? if not stop
Messagebox "No such document in MDP database."
Exit Sub
Else
Dim item As Variant
item = doc.GetItemValue( "ECRNumLkup" )
Set agent = db2.GetAgent("(CSRMailSendLS)")
Messagebox "OK so here is what you are looking for in the MDP database " + item(0),,"Hi Teri"
If agent.Run = 0 Then
Call agent.run
Messagebox "Agent ran",, "Success"
Else
Messagebox "Agent did not run",, "Failure"
End If
Exit Sub
End If
The above code once clicked, produces the messagebox below with the correct number.
Messagebox "OK so here is what you are looking for in the MDP database " + item(0),“Hi Teri”
It then gives me the Messagebox “Agent ran”, “Success”
However, the problem is that I am not getting mail. I have made sure that my name is in the mailsend code.
Thanks in advance for any help you can give me.
Teri