Groups > Novell > Novell Developers discussion > Re: C3po to limit the amount of mail recipients - how to resolve




C3po to limit the amount of mail recipients - how to resolve
groups?

C3po to limit the amount of mail recipients - how to resolve groups?
Thu, 21 Sep 2006 08:25:59 GMT
Hi All,

I have been tasked with creating functionality to limit the amount of
recipients that users may send an email to.  The organisation has been
plagued by users who need to send a message to 100 or so recipients so,
instead of creating a group of these people they simply send their message
to everyone in the organisation (about 1000).  Apart from being annoying
to those for whom the message is not intended, it can cause massive
overheads on what is an already overloaded mail server.

The c3po I have created using VB6 traps the "send message" event and
uses
the ItemGetText command to read all of the recipient's email addresses in
the To: box:

ParamStr = "ItemGetText(""" + MyMessageID +
"""; 0)"
iRet = vCommander.Execute(ParamStr, adrTo)

I than use the "split" command using a semi colon as the delimiter to
create an array of individual email addresses, the UpperBound of this
array now contains the amount of intended recipients.  If this value is
greater than 50 then an appropriate message is displayed and the email
blocked.

My question is, if I was to create a Group which contained 51 users and
sent an email to this group, the ItemGetText command would only return the
name of the group so the c3po would think that there is only one intended
recipient.  Is there a command which will "open out" the group before
I
count the number of recipients?

I have searched all of the available documentation and thought that the
AddressList command would work:

Dim strAddressList As String
Dim strReturnValue As String
iRet = vCommander.Execute("addresslistcreate()", strAddressList)
ParamStr = "AddressListGetCount(" + Val(strAddressList) +
";233)"
iRet = vCommander.Execute(ParamStr, strReturnValue)

But this only returns a value of 0 or 1.

I would really appreciate any suggestions.

Thanks in advance.           
Post Reply
Re: C3po to limit the amount of mail recipients - how to resolve groups? (Solved)
Thu, 21 Sep 2006 11:22:09 GMT
I'found the solution, I thought I would post it here just in case anyone
else has a similar problem.

I was using the AddressListCreate command but not specifying what to
create the addresslist from, the solution is to use the
AddressListCreateFromGroup command and pass the name of the group as a
parameter, so, instead of:

Dim strAddressList As String
Dim strReturnValue As String
iRet = vCommander.Execute("addresslistcreate()", strAddressList)
ParamStr = "AddressListGetCount(" + Val(strAddressList) +
";233)"
iRet = vCommander.Execute(ParamStr, strReturnValue)

You must specify the name of the group to create the addresslist from. 
First check that the address is in fact a group and not an email address:
single recipients are displayed as Davies, John or John.Davies@etc.com, so
you can check if the entry is a group by looking for a comma or an @ sign:

If ((InStr(1, Trim(adrTo), ",") = 0) And (InStr(1, Trim(adrTo),
"@") = 0))
Then
     'It is a group, resolve the entry              
     ParamStr = "AddressListCreateFromGroup(""" + adrTo +
""";)"
     iRet = vCommander.Execute(ParamStr, strAddressList)
     ParamStr = "AddressListGetCount(" + strAddressList +
";233)"
     iRet = vCommander.Execute(ParamStr, strReturnValue)
     intNumberofRecipients = intNumberofRecipients + Val(strReturnValue)
End If

Thank you for your time
Post Reply
Re: C3po to limit the amount of mail recipients - how to resolve
Thu, 21 Sep 2006 17:16:15 GMT
Hello,

I think you better post this on the groupwise c3po devsup forum.


sync_or_swim wrote:
> I'found the solution, I thought I would post it here just in case anyone
> else has a similar problem.
> 
> I was using the AddressListCreate command but not specifying what to
> create the addresslist from, the solution is to use the
> AddressListCreateFromGroup command and pass the name of the group as a
> parameter, so, instead of:
> 
> Dim strAddressList As String
> Dim strReturnValue As String
> iRet = vCommander.Execute("addresslistcreate()", strAddressList)
> ParamStr = "AddressListGetCount(" + Val(strAddressList) +
";233)"
> iRet = vCommander.Execute(ParamStr, strReturnValue)
> 
> You must specify the name of the group to create the addresslist from. 
> First check that the address is in fact a group and not an email address:
> single recipients are displayed as Davies, John or John.Davies@etc.com, so
> you can check if the entry is a group by looking for a comma or an @ sign:
> 
> If ((InStr(1, Trim(adrTo), ",") = 0) And (InStr(1, Trim(adrTo),
"@") = 0))
> Then
>      'It is a group, resolve the entry              
>      ParamStr = "AddressListCreateFromGroup(""" + adrTo
+ """;)"
>      iRet = vCommander.Execute(ParamStr, strAddressList)
>      ParamStr = "AddressListGetCount(" + strAddressList +
";233)"
>      iRet = vCommander.Execute(ParamStr, strReturnValue)
>      intNumberofRecipients = intNumberofRecipients + Val(strReturnValue)
> End If
> 
> Thank you for your time
Post Reply
about | contact