Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Combine Querysend and Agent

Posted on 2009-05-12
4
Medium Priority
?
644 Views
Last Modified: 2013-12-18
Hey Experts, I have a querysend that basically appends some text to the subject line then emails a copy of the email to a mail in db. In the mail in db I have an agent that checks a field if it contains more then 1 clientname then it creates a copy of that email for each JOBNUMBER in the email. What I'd like to do is combine these agents so that when the email is sent the querysend will detect the multiple client names and instead of emailing one email to the mail in db it will create a separate email for each jobnumber.....I've posted the code for the query send and the spit jobnumbers agent......The split jobnumbers agent actually deletes the original email that is rec'd in the mail in db after it has created the individual documents this would not be necessary if it is split before it arrives.....
Sub Querysend(Source As Notesuidocument, Continue As Variant)
	'Check preference and Warn if subject is blank for a new memo
	If source.Document.EnableBlankSubject(0) <> "1" Then
		If source.document.Subject(0) = "" Then
			If Messagebox(warnTxt, MB_YESNO + MB_ICONQUESTION, warnTitle ) = IDNO Then 
				vSubjectBlankSend = False
				Source.GoToField("Subject")
				Call source.Refresh
				Call cMemoObject.SetActionInProgress(MEMO_ACTION_NONE)
				Call Source.Document.ReplaceItemValue("SaveOptions","0")
				cMemoObject. SendBlankSubject=False
				continue = False		
				Exit Sub
			Else
				vSubjectBlankSend = True
				cMemoObject. SendBlankSubject=True
			End If
		End If
	End If
	
	If source.Document.HasItem("ActionInProgress") Then
		source.Document.RemoveItem("ActionInProgress")
	End If
	If source.Document.JobNumber(0) = "" Then
		
	Else
		'Remove old jobnumbers before mailing
		If Instr(source.Document.subject(0)," [" ) = 0 Then
		Else
			Subject$ = Trim(Strleft(source.Document.Subject(0),"["))
			Call Source.FieldSetText("Subject",Subject$)
		End If
		
		Dim CustomerName As Variant
		Dim CustomerJob As String
		Dim JobNumber As Variant
		ClientName_1 = source.Document.CustomerJob
		JobNumber  = source.Document.JobNumbers
		Call source.document.replaceitemvalue("Customerjob",Join(ClientName_1, ";")) 
		Call source.FieldAppendText("Subject"," [" & Join(JobNumber, ";") &"]") 		
		If Instr(source.Document.EnterBlindCopyTo(0),"jobcorrespondence@mail.com]") = 0 Then
			Call source.FieldAppendText("EnterBlindCopyTo","JobCorrespondence@mail.com")
		End If
		Call Source.FieldSetText("Customer",Join(ClientName_1, ";")) 		
		jobnumbers =source.Document.Jobnumber
		Call source.document.ReplaceItemValue("Filed","Yes")
		Call source.document.Save(True,False)	
	End If
End Sub
 
 
Sub Initialize
	Dim session As New NotesSession
	Dim jobnumberList As Variant
	Dim db As NotesDatabase
	Dim docA As NotesDocument
	Dim docB As NotesDocument
	Dim DeleteMe As String
	Dim collection As NotesDocumentCollection
	
	
	Set db = session.CurrentDatabase
	Set collection = db.UnprocessedDocuments
	Set docA = collection.GetFirstDocument()
	Call docA.refresh
	'If Instr(docA.CustomerJob(0),"; " ) = 1 Then
	If Instr(docA.ClientName_1(0),"; " ) = 1 Then
	'If Ubound(docA.CustomerJob) >0 Then
		
	Else
		
		If Not (docA Is Nothing) Then
			jobnumberList = docA.GetItemValue("jobnumber")
			Forall x In jobnumberlist
				Set docB = New NotesDocument( db )
				Call docA.CopyAllItems( docB, True )
				docB.jobnumber = Instr(docA.jobnumber(0),";" ) = 1
				docB.jobnumber = x	
				docB.clientname =""
				docB.clientname_1 =""
				docB.customer = ""
				Call docB.ComputeWithForm(True, True)
				Call docB.Save( True, True )
				
			End Forall
		End If
	End If
	
	If Instr(docA.ClientName_1(0),"; " ) = 0 Then
	'If Instr(docA.ClientName_1(0), Chr$(13))>0 Then	
	'If Ubound(docA.CustomerJob) < 1 Then	
		docA.Remove(True)
	End If
End Sub

Open in new window

0
Comment
Question by:padillrr
[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
  • 3
4 Comments
 
LVL 3

Accepted Solution

by:
tiler earned 2000 total points
ID: 24442573
I'm sorry this is not exactly a direct answer to your question, but why would you want to do this? I think it's better to send one email and let it be picked apart, if necessary, at the receiving end. Sending multiple emails is more of a load on your servers doing the mail routing, there's a longer delay for the user because more work is being done on their workstation, and if you decide to change how the system works later and keep the emails together as a single document at the receiving end (which I advise), you can do that without having to worry whether everyone's mail file has the updated code.
0
 

Author Comment

by:padillrr
ID: 24558548
Good suggestion, I guess the real problem I'm having is the split agent is not running properly there are certain emails that it chokes on .....
0
 

Author Comment

by:padillrr
ID: 24583995
I have to agree, I will try to get the split agent to run properly or try to figure out why the emails getting into the mail in db are getting somehow corrupted where the split agent will not run...Thanks
0
 

Author Closing Comment

by:padillrr
ID: 31580695
Didn't really solve the issue but thanks for the help...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

671 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