/ Forums / Advansys Formativ / Free Solutions from GroupWise Cool Solutions or Advansys / QuickSend applet – Groupwise crash when send to large numbers / Reply To: QuickSend applet – Groupwise crash when send to large numbers
December 19, 2006 at 3:58 pm
#8335
Please see below the source code of the “Quick Send” applet. You need to copy the source code and paste into an applet. You need the Formativ Creator or Studio (http://www.advansyscorp.com/formativ_framework.htm) to create and manage the applet. Please note, Advansys do not provide support for the example and cool solutions solution. Hope this helps.
'-------------------------------------------------------------------------------
' Formativ Solutions for GroupWise
' Quick Send
' Designed by: Formativ Business Solution Team
' Copyright (c) 2003 Advansys Pty Limited (www.advansyscorp.com)
' Version 1.0
'
' DESCRIPTION:
' Sends one copy of the current open email message to each recipient email
' address stored in a flat text file.
'
'
' NOTES:
' - The text file must contain one email address per line.
' - The email address must contain the '@' character. The applet ignores
' address(s) not containing the '@' character.
' - Run the applet by pressing the button that appears on a composing email
' message toolbar.
' - You must save the composing email message before you can run the applet.
' - The applet has been tested with GroupWise 6.5.1 and 6.0.2
'
'
' HISTORY:
' 19 June 2003 MA: Initial release
'
' 2006-08-08 MA 1.0.1
' - Utilities.doevents added when sending and cloning messages.
' We need to forces Windows to process any pending messages in the Windows application message queue
' when sending large groups.
'-------------------------------------------------------------------------------
const IDS_CAPTION = "Formativ Business Solutions"
const IDS_NO_MSG_VIEW = "An error occurred while locating the saved message. Close all message(s) views, then open the master draft message and run the applet again."
const IDS_SAVE_MSG = "Please save the message (CTRL+S) and run the applet again to proceed."
const IDS_EMPTY_FILE = "The selected recipients file is empty."
const IDS_CONFIRMATION = " email messages will be generated. Do you want to proceed?"
const IDS_MSG_BOX_TYPE = "The message is not draft. Please run the applet from a composing or draft message toolbar."
const IDS_INVALID_MSG = "Unable to access the message. Please save and close the message, then open the message and try again."
const IDS_FILE_SELECT_DLG = "Select the address text file..."
const IDS_INVALID_ADDRESS = "This file does not contains any valid email addresses."
const IDS_STATUS_INIT = "Initializing...[Please wait]"
const IDS_STATUS_SEND = "Sending Messages...[Please wait]"
const IDS_MESSAGES_SENT = "Total messages sent: "
'-->Flexalock
dim gStatusDlg
'-------------------------------------------------------------------------------
' Main Line processing
'-------------------------------------------------------------------------------
Sub Main(Client, GWEvent)
dim iRecipientsList
on error resume next
set gStatusDlg = Utilities.NewStatusDialog
iMessageID = GroupWise.ItemMessageIDFromView
' Do we have a valid message ID?
if not IsValidMessageID(iMessageID) then
exit sub
end if
' Find the message
set iMsg = groupwise.account.GetMessage(iMessageID)
' Do we have the message object?
if not isobject(iMsg) then
gStatusDlg.hide
call msgbox(IDS_INVALID_MSG, vbCritical, IDS_CAPTION)
exit sub
end if
' Make sure the message type is draft
if (iMsg.BoxType <> fgwDraft) then
gStatusDlg.hide
call msgbox(IDS_MSG_BOX_TYPE, vbCritical, IDS_CAPTION)
exit sub
end if
set iRecipientsList = utilities.stringlist
' Select the addresses list file and validate the addresses
if not SelectRecipientsList(iRecipientsList) then
exit sub
end if
gStatusDlg.hide
' Confirmation message box before sending the message to the recipients
if (MsgBox (iRecipientsList.count & IDS_CONFIRMATION, vbOKCancel+vbInformation, IDS_CAPTION) = vbCancel) then
exit sub
end if
' Send messages
call SendMessage(iRecipientsList, iMsg)
Set iMsg = nothing
End Sub
'-------------------------------------------------------------------------------
' Send the message to the recipients
'-------------------------------------------------------------------------------
sub SendMessage(aList, aMsg)
dim x
dim iDlg
dim iAddress
dim iMasterMsg
dim iCloneMsg
dim iCounter
dim iListBoxCtl
dim iSentMsg
dim iTotalMessages
on error resume next
iTotalMessages = 0
if not isobject(aMsg) then
exit sub
end if
if (aList.count = 0) then
exit sub
end if
gStatusDlg.Title = IDS_STATUS_SEND
gStatusDlg.ProgressRange = aList.count
gStatusDlg.show
set iSentItemsList = utilities.stringlist
utilities.doevents
set iMasterMsg = aMsg.Clone
set iDlg = Utilities.NewControlBoxDialog
set iListBoxCtl = iDlg.AddListBoxControl
' Clear all recipients if exists
iCounter = iMasterMsg.Recipients.count
if (iCounter > 0) then
for x = 1 to iCounter
iMasterMsg.Recipients.item(x).delete
next
end if
' Sending messages to each recipients
for x = 0 to aList.count -1
iAddress = trim(aList.strings(x))
if (iAddress <> "") then
'utilities.trace("iAddress: " & iAddress)
' Clone the message
utilities.doevents
set iCloneMsg = nothing
set iCloneMsg = iMasterMsg.clone
utilities.doevents
call iCloneMsg.Recipients.add(iAddress)
' Send the message
set iSentMsg = nothing
set iSentMsg = iCloneMsg.send
' Make sure we have send the message
if (iSentMsg.MessageID <> "") then
iListBoxCtl.items.add(iAddress)
end if
utilities.doevents
iCloneMsg.delete
if not iSentMsg is nothing then
iTotalMessages = iTotalMessages + 1
gStatusDlg.StatusText = IDS_MESSAGES_SENT & iTotalMessages
end if
set iSentMsg = nothing
set iCloneMsg = nothing
end if
gStatusDlg.ProgressPosition = x
next
iMasterMsg.delete
iMasterMsg.delete
gStatusDlg.hide
iDlg.Caption = IDS_CAPTION
iDlg.title = iListBoxCtl.items.count & " messages sent to:"
iDlg.Button2Visible = FALSE
iDlg.execute
set iMasterMsg = nothing
end sub
'-------------------------------------------------------------------------------
' Is the message ID is valid?
'-------------------------------------------------------------------------------
function IsValidMessageID(aID)
IsValidMessageID = FALSE
if (len(aID) = 0) then
exit function
end if
if (instr(1, aID, "Token failed execution", 1) <> 0) then
gStatusDlg.hide
call msgbox(IDS_NO_MSG_VIEW, vbExclamation, IDS_CAPTION)
exit function
end if
if (aID = "X00") then
gStatusDlg.hide
call msgbox(IDS_SAVE_MSG, vbExclamation, IDS_CAPTION)
exit function
end if
IsValidMessageID = TRUE
end function
'-------------------------------------------------------------------------------
' Select the recipients list file and make sure the contents are valid
'-------------------------------------------------------------------------------
function SelectRecipientsList(byref aList)
aList.clear
SelectRecipientsList = FALSE
dim iFileCTL
' Display file select dialog
Set iFileCTL = Utilities.NewOpenFileDialog
iFileCTL.Title = IDS_FILE_SELECT_DLG
iFileCTL.Filter = "Text File (*.txt)|*.TXT"
gStatusDlg.hide
' Execute the file select dialog
if not iFileCTL.execute then
exit function
end if
dim x
dim iAddress
dim iTempList
set iTempList = utilities.stringlist
iTempList.LoadFromFile(iFileCTL.Filename)
gStatusDlg.Title = IDS_STATUS_INIT
gStatusDlg.ProgressRange = iTempList.count
gStatusDlg.show
if (iTempList.count = 0) then
gStatusDlg.hide
call msgbox(IDS_EMPTY_FILE, vbExclamation, IDS_CAPTION)
exit function
end if
' Validate the address(s).
' - Make sure we have @ characters in the address
' - Do not include duplicate address
for x = 0 to iTempList.count -1
iAddress = iTempList.strings(x)
if (instr(1, iAddress, "@", 1) <> 0) and (len(iAddress) > 1) and (aList.indexof(iAddress) = -1) then
aList.add(iAddress)
end if
gStatusDlg.ProgressPosition = x
next
' Do we have any address(s) after validate?
if (aList.count = 0) then
gStatusDlg.hide
call msgbox(IDS_INVALID_ADDRESS, vbExclamation, IDS_CAPTION)
exit function
end if
SelectRecipientsList = TRUE
end function
Regards,
Advansys Support