Link to home
Start Free TrialLog in
Avatar of ba_pepper
ba_pepper

asked on

Scripting - Modify Send button - multiple batches

I have a requirement to break a mailing into several batches. The form contains a RichText field (Body) that I am having difficulty with. I have been unsuccesful accessing this field.

old button contents:
REM @Command([MailSend]);
REM @Command([FileSave]);
REM @Command([FileCloseWindow])

new script:
Sub Click(Source As Button)
     On Error Goto ErrorHandler
     
     Dim session As New NotesSession
     Dim workspace As New NotesUIWorkspace
     Dim db As NotesDatabase
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument
     Set db = session.CurrentDatabase    
     Set uidoc = workspace.CurrentDocument
     Set doc = uidoc.Document
     
     saveBCC = Evaluate( "@Unique(BlindCopyTo)", doc )
     
     uLimit = Ubound(saveBCC)
     batchSize = 1
     y = 0  
     
     Set sentBCC = doc.GetFirstItem( "BlindCopyTo" )
     doc.BlindCopyTo = ""
     
     For x = 0 To uLimit
          sentBCC .AppendToTextList( saveBcc(x) )
          y = y + 1
          If y >= batchSize Or x = uLimit Then
REM               y =  Evaluate("@MailSend ")
               Call doc.Save( True, True)
               Call doc.Send( False )
               
               Messagebox "sentBcc: " & sentBCC .Text
               y = 0  
               doc.BlindCopyTo = ""
          End If
     Next x  
     Exit Sub
     
ErrorHandler:
     Messagebox "Error " & Err() & ":  " & Error()
     Exit Sub
     
End Sub
Avatar of HemanthaKumar
HemanthaKumar

I see this if condition confusing

If y >= batchSize Or x = uLimit Then, which says if y which is initialy 0 +1 >= 1... then resetting it back to 0 in the if condition.. is equivalent to true always. And you are looping x = 0 to ulimit, and again checking x = ulimit doesn't make sense.

What is your intention ?

If you want to breakup bcc field data into certain chunks then you can use counter which will collect subsets of the data and send it.. Also Where is Richtext field ?

~Hemanth
Avatar of ba_pepper

ASKER

possible, I would like to focus on accessing the RTF field -  Body, any ideas?
U mean u want to manipulate body field .. hope this example helps,
Dim doc As NotesDocument
Dim rtitem As Variant

Set rtitem = doc.GetFirstItem( "Body" )
If rtitem.Type = RICHTEXT Then
  Call rtitem.AddNewLine( 1 )
  Call rtitem.AppendText _
  ( "what ever u want to type u can type" )
End If
Call doc.Save( False, True )

Partha
Well partha covered it pretty much.

needed to focus on the uidoc.... Answer below


Sub Click(Source As Button)
     On Error Goto ErrorHandler
     
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument    
     Set uidoc = workspace.CurrentDocument
     Set doc = uidoc.Document
     
     uidoc.Send
     
     Exit Sub
     
ErrorHandler:
     Messagebox "Error " & Err() & ":  " & Error()
     Exit Sub
     
End Sub
Sub Click(Source As Button)
     On Error Goto ErrorHandler
     
     Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument    
Dim rt as notesRichTextItem
     Set uidoc = workspace.CurrentDocument
     Set doc = uidoc.Document
     
set rt = doc.GetFirstItem("Body")
rt.AddNewLine(1)
rt.AppendText( "Here is my line added to the rich text")
Call doc.Send(false)
     
     Exit Sub
     
ErrorHandler:
     Messagebox "Error " & Err() & ":  " & Error()
     Exit Sub
     
End Sub
Hi ba_pepper,

None of the experts here has any idea whether you still have a problem or not, nor what the problem was.  Is this closed?

Best regards,
qwaletee
Sorry should have stated problem resolved.

Look at prior post for answer (code snippet).

The problem was when sending the doc the RTF field ( Body ) was not being included, the solution was send the uidoc.
close this problem
Ask for a refund using community support.
ASKER CERTIFIED SOLUTION
Avatar of SpazMODic
SpazMODic

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial