Solved

Passing in a value from the Subject Line of Current Document in to a sub in a agent

Posted on 2008-10-08
4
195 Views
Last Modified: 2013-12-18
I have a agent that runs when new documents arrive.  The agent creates a new email and sends it to a user that is listed in the message of the document.  I would like to pass the value of the subject line of the current document to the subject line of the agent created email.  The agent is using a sub and I am not sure how to pass the value.

I will paste the agent

I want memo2.Subject to have the same value as the Subject of the current document.  If not for using the sub I would try something like

memo2.Subject = cur.Subject
Sub Initialize

	Dim s As New NotesSession

	Dim db As NotesDatabase

	Dim c As NotesDocumentCollection

	Dim cur As NotesDocument

	

	Set db = s.CurrentDatabase

	Set c = db.UnprocessedDocuments

	

	Set cur = c.GetFirstDocument

	Do Until cur Is Nothing

		If Not cur.HasItem( "flagProcessed" ) Then                'if it doesn't have flag - process it

			Call SendMemoFromTag( cur, "username", Chr(10) )

			Call cur.ReplaceItemValue( "flagProcessed", "1" )      'flag the processed e-mail

			Call cur.Save( True, False, True )                                'you must save the change in the doc

		End If

		Set cur = c.GetNextDocument( cur )

	Loop

End Sub
 
 
 
 

Sub SendMemoFromTag(memo As NotesDocument, Byval tagStart As String, Byval tagEnd As String)

	

	Dim sess As New NotesSession

	Dim parts As Variant

	Dim body As String, sendto As String

	sess.ConvertMime = True

	body = memo.GetItemValue("Body")(0)

	If (Instr(1, body, tagStart, 5) = 0) Then Exit Sub

	parts = Split(body, tagStart)

	If (Instr(1, parts(1), tagEnd, 5) = 0) Then sendto = Trim(parts(1)) Else sendto = Trim(Strleft(parts(1), tagEnd))

	

	Dim memo2 As NotesDocument

	Set memo2 = memo.ParentDatabase.CreateDocument

	

	line1  = "Job Number: " & OrderNo & Chr(10)

	line2 = "Requester Name: " & sendto & Chr(10)

	line3 = "Your job has been completed by the model shop." & Chr(10)

	line4 = "If you have any questions please contact us" & Chr(10)

	

	memo2.Form = "memo"

	memo2.Subject = "Your Model Shop request has been completed."

	memo2.Body = line1 +  line2 + line3 + line4 

	memo2.SendTo = sendto

	Call memo2.Send(False)

	

End Sub

Open in new window

0
Comment
Question by:Jaziar
  • 2
  • 2
4 Comments
 
LVL 63

Accepted Solution

by:
SysExpert earned 250 total points
ID: 22673468
It may work in any case , just change it to

memo2.Subject = memo.Subject

and  place it after

 memo2.SendTo = sendto


I hope this helps !
0
 

Author Comment

by:Jaziar
ID: 22673663
What if I wanted to put the value in the body of the text??
0
 
LVL 63

Expert Comment

by:SysExpert
ID: 22673925
add a line5 as

 line5 = memo.Subject

and put it where you want in the order where the lines are appended
  memo2.Body = line1 +  line2 + line3 + line4 + line5

Change the order for your needs.

0
 

Author Comment

by:Jaziar
ID: 22678321
I get a type mismatch when I try that
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

Suggested Solutions

Title # Comments Views Activity
Lotus Notes 41 185
Lotus Notes Mail Database issues 2 899
Send email lotus notes / VBA 6 167
Lotus Domino server 9 7 69
  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…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

895 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

12 Experts available now in Live!

Get 1:1 Help Now