I’m creating a button that has several functions. First it will check the mail in db to see if the email has already been filed if it has then exits, if not it will present a picklist for the user to select under which job ref to file it under (can be more then one) once the user selects the job refs and clicks OK the selected email should be mailed into the mail in db and marked as filed in the users mail file. I have the check working, but I cannot get the selected job refs to be appended to the subject line and emailed to the mail in db. I keep getting a type mismatch. It’s been suggested to use the Join function but Ican’t get that to work either I need some suggestions. I’ve included my button code. This button is located in the Inbox folder and must work from the view on all selected documents.
Sub Initialize
Dim s As New notesSession
Dim ws As New notesUIWorkspace
Dim uiview As notesUIView
Dim db As notesDatabase
Dim dc As notesDocumentCollection
Dim doc As notesDocument
Dim body As String
Dim memo As notesDocument
Dim n As Integer
Dim newdoc As notesDocument
Dim newi As notesItem
Dim i As notesItem
Dim count As Integer
Dim agent As notesAgent
Dim memobody As notesRichTextItem
Dim docbody As notesRichTextItem
Dim docitem As notesItem
Dim refnums As Variant
Dim response As Variant
Dim uidoc As NotesUIDocument
Dim jobcorDB As NotesDatabase
Dim askme As Integer
Dim messageid As Variant
Dim messageview As NotesView
Dim existingdoc As NotesDocument
Dim subject As String, customerName As String, jobNumber As String, h As String
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set uiview = ws.CurrentView
Set agent = s.Currentagent
If DC.Count > 1 Then
askme = ws.Prompt (PROMPT_YESNO, _
"Ref Number Useage", "Use same Ref # for all selected messages?")
End If
Set jobcorDB = New notesdatabase("domino1/dalinalaw","jobcor2.nsf")
refnums = Evaluate({@DbColumn ("" : "NoCache"; "domino1/dalinalaw":"dalinatime.nsf"; "Customer Jobs2"; 1)},dc.GetFirstDocument)
If askme = 1 Then
response = ws.Prompt (PROMPT_OkCancelListMult, "Select a Ref Number","Select a Ref Number To Apply To These Messages.", refnums(0),refnums)
End If
For n = 1 To dc.Count
Set doc = dc.GetNthDocument(n)
messageid = doc.GetItemValue("$MessageID")
Set messageview = jobcordb.GetView("(ByMessageID)")
Set existingdoc = messageview.GetDocumentByKey(MessageID(0))
If existingdoc Is Nothing Then
Else
Messagebox "This message was already added by " & Trim(Strrightback(Strleftback(existingdoc.Authors(0),"/"),"="))
JobNumber$ = Trim(Strrightback(Strleftback(existingdoc.subject(0),"]"),"["))
If Instr(doc.subject(0)," [" & JobNumber$ & "]") = 0 Then
Call doc.ReplaceItemValue("Subject",doc.subject(0) & " [" & JobNumber$ & "]")
End If
Goto finish
End If
If askme = 1 Then
Else
response = ws.Prompt (PROMPT_OkCancelListMult, "Select a Ref Number","Select a Ref Number To Apply To These Messages.", refnums(0),refnums)
End If
CustomerName = Trim(Strleft(response,"-"))
JobNumber = Trim(Strrightback(Strleftback(response,"|"),":"))
If Instr(memo.subject(0)," [" & JobNumber & "]") = 0 Then
Call memo.ReplaceItemValue("Subject",memo.subject(0) & " [" & JobNumber$ & "]")
End If
If Instr(source.Document.EnterBlindCopyTo(0),"jobcorrespondence@email.com]") = 0 Then
Call source.FieldAppendText("EnterBlindCopyTo",",JobCorrespondence@email.com")
End If
Call Source.FieldSetText("Customer",CustomerName$)
Call source.Document.ReplaceItemValue("Filed", "Yes")
Call source.Document.Save(True, False)
finish:
Call doc.ReplaceItemValue("Filed","Yes")
Call doc.Save(True,False)
Call doc.send(False)
count = count + 1
Next n
End Sub