I have the requirement to go through each sendee of a mail (whether it be a group or an individual) and count how many people are going to receive the e-mail. If the total number is greater than 50, I need to prompt the user to agreeing that they meant to send it to that many people. I get the code to count and to prompt, as well as to send the e-mail. My problem is that it will not save the e-mail if the user either chooses to save it (if their preference is to always prompt on send) or save it automatically (if their preference is to always keep a copy). I have checked to make sure the saveoptions flag is set to "1" (and it is), so I am at a loss. Below is my code. Anyone see the issue?
OPTIONS
Use "CoreEmailClasses"
DECLARATIONS
Dim prompt_title As String
Dim prompt_message As String
Dim view As NotesView
Dim nab_db As NotesDatabase
Dim nab_view As NotesView
Dim nab_doc As NotesDocument
Dim counter As Integer
Sub Click(Source As Button)
<br/>
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim session As New NotesSession
Dim totalList() As String 'array of all the entries in the to, cc, and bcc fields
Dim totalListCounter As Integer
Dim doc As NotesDocument
Dim db As NotesDatabase
<br/>
Set uidoc = workspace.CurrentDocument
'set the message box's title and message prompt
prompt_title = "Send to Large Audience?"
prompt_message = "Please be advised, you are sending this email to a large audience. Continue?"
counter = 0
Set db = session.CurrentDatabase
Set doc = uidoc.Document
totalListCounter = -1
'Gather all of the entries in the to field into the TotalList array
new_counter = -1
If doc.GetItemValue("EnterSendTo")(0) <> "" Then
Forall i In doc.EnterSendTo<br/>
totalListCounter = totalListCounter + 1<br/>
Redim Preserve totalList(totalListCounter) As String<br/>
totalList(totalListCounter) = i<br/>
End Forall<br/>
End If
<br/>
'Gather all of the entries in the cc field into the TotalList array
If doc.GetItemValue("EnterCopyTo")(0) <> "" Then
Forall i In doc.EnterCopyTo<br/>
totalListCounter = totalListCounter + 1<br/>
Redim Preserve totalList(totalListCounter) As String<br/>
totalList(totalListCounter) = i<br/>
End Forall<br/>
End If
<br/>
'Gather all of the entries in the bcc field into the TotalList array
If doc.GetItemValue("EnterBlindCopyTo")(0) <> "" Then
Forall i In doc.EnterBlindCopyTo<br/>
totalListCounter = totalListCounter + 1<br/>
Redim Preserve totalList(totalListCounter) As String<br/>
totalList(totalListCounter) = i<br/>
End Forall<br/>
End If
<br/>
'Get a handle onto the nab
Set nab_db = New NotesDatabase(db.Server, "names.nsf")
Set nab_view = nab_db.GetView("($VIMGroups)")
<br/>
'call the function that will count the number of users the email will be going to
temp = resolveGroups(TotalList)
<br/>
'if the number returned > 50, ask if the user still wants to send the message
If temp > 50 Then
answer = workspace.Prompt(PROMPT_YESNO,prompt_title, prompt_message)<br/>
'If they still want to send the message, call the email core class to send the message and
'close the window
If answer = 1 Then<br/>
doc.ActionInProgress = MEMO_SEND<br/>
Continue = True<br/>
Call uidoc.FieldSetText("useApplet", "True")<br/>
Call cMemoObject.QuerySave(Continue)<br/>
If continue = True Then<br/>
Call uidoc.Close<br/>
End If<br/>
End If<br/>
<br/>
'if the total amount <= 50, call the email core class to send the message and
'close the window
Else<br/>
doc.ActionInProgress = MEMO_SEND<br/>
Continue = True<br/>
Call uidoc.FieldSetText("useApplet", "True")<br/>
Call cMemoObject.QuerySave(Continue)<br/>
If continue = True Then<br/>
Call uidoc.Close<br/>
End If<br/>
End If<br/>
<br/>
End Sub
Function ResolveGroups(groupnames As Variant)
Dim session As New NotesSession
Dim abdoc As NotesDocument
Forall i In groupnames
'if the entry being evaluated is = to All, automatically set the return value to 51
'(higher than the max allowed to be sent without the message)
If i = "All" Then<br/>
ResolveGroups = 51<br/>
Exit Forall<br/>
End If<br/>
<br/>
'check in the nab to see if the current entry is a group. if it is, check each member<br/>
'entry to see if there is a group nested. if yes...recall the function. Each member<br/>
'found will be added to the counter<br/>
Set can_name = session.CreateName(i)<br/>
Set abdoc = nab_view.GetDocumentByKey(can_name.Common)<br/>
If Not abdoc Is Nothing Then<br/>
If abdoc.HasItem("members") Then<br/>
group_names = abdoc.members<br/>
Call resolveGroups(group_names)<br/>
End If<br/>
Else<br/>
counter = counter + 1<br/>
'if at any point during the process the counter gets greater than 50, stop executing
'the function
If counter > 50 Then<br/>
Exit Forall<br/>
End If<br/>
<br/>
End If<br/>
End Forall
<br/>
'send the total found back to the main process
ResolveGroups = counter
<br/>
End Function