Next, the formula to put in all the send actions: I should also say that I also had the requirement to send an email to a particular person in the event someone tried to mail a restricted group.
REM {**********************************************************************************};
REM {Check authorization for ability to mail M&M store groups};
REM {**********************************************************************************};
REM {Variables};
CLASS := “Notes”;
NOCACHE := “NoCache”;
CACHE := “Cache”;
SERVER := “”;
DATABASE := “”;
VIEW := “($Keyword Fields)”;
KEY := “M&MGroupsBlockList”;
FIELDNAME := “KeyList”;
KWSERVER := “”;
KWDB := “”;
KWV := “($Keyword Fields)”;
KWK1 := “M&MGroupsA-H”;
KWK2 := “M&MGroupsM-T”;
KWF := “KeyList”;
AuthList := @DbLookup(CLASS : NOCACHE; SERVER : DATABASE;VIEW; KEY; FIELDNAME);
ismember := @If(!@IsMember( @Name([CN]; @UserName);@Name([CN];AuthList));“0”;“1”);
AddrLookup := @Implode( @Trim( SendTo : EnterSendTo : CopyTo : EnterCopyTo : BlindCopy : EnterBlindCopy : BlindCopyTo : EnterBlindCopyTo ); “,” );
Keywordlookup1 := @DbLookup(CLASS : NOCACHE; KWSERVER : KWDB; KWV; KWK1; KWF);
Keywordlookup2 := @DbLookup(CLASS : NOCACHE; KWSERVER : KWDB; KWV; KWK2; KWF);
kwcheck := @Keywords(“,”+AddrLookup;Keywordlookup1:Keywordlookup2;“,”);
FIELD tmpAuthError := @If(kwcheck =“”;“0”;“1”);
tmpTemp := @If( tmpAuthError = “1”; @Do(
@If(ismember = “0”;
@DeleteField;
@Prompt([Ok]; “Operation Not Permitted”; " Your email has been denied. If you wish to communicate to an M&M store group, please use the Store Mail application. Please contact at or at if you have any questions")));
@DeleteField);
@If( tmpAuthError = “1”; @Do(@If(ismember = “0”;
@DeleteField;@Return(@MailSend( “John Doe/ACME” ;“” ;“” ;“Store Mail Restriction Notification” ; “” ; @Name([CN];@UserName)+" attempted to send mail to a restricted group containing the subject <“+Subject+”>"))));@DeleteField);
This all worked great, but there was still some problems. I had a new requirement to stop the mail message if they tried to send it to more than 19 people in my store environment. As if that wasn’t a problem enough, I also had the problem of people making local groups containing hundreds of store users and sending out emails that way. I did this by first expanding local groups if the user was in the restriction group and then counting the number of messages by keying on text that would exist in each address. So the rest of the code looks like this:
FIELD $ExpandGroups := @If(ismember= “1”; “1”;“”);
@If(ismember = “1”;@Command([ViewRefreshFields]); “”);
AddrLookup2 := @Implode( @Trim( SendTo : CopyTo : BlindCopy ); “,” );
@If(ismember = “1”;@Do(
strSource := AddrLookup2;
strSub := " OU=ACME";
strTmp := @ReplaceSubstring(strSource;strSub;“|”);
strSplit := @Explode(strTmp;“|”;@True);
mcount := @Elements(strSplit) - 1)
;@DeleteField);
@If
(mcount > 19;@Return(@Prompt([Ok];“Operation Not Permitted”;“Your may not send to more than 19 M&M store email accounts. Please contact at or at if you have any questions”));@DeleteField);
And of course all this code goes above the stock:
MEMO_SEND:=“1024”;
FIELD ActionInProgress:=MEMO_SEND;
@If(@Command([FileSave]);@Command([FileCloseWindow]);@Return(“”))
Now there is much in all this that is written to my environment (and I replaced real names with fictitious ones) so this will not work for just anyone to copy and paste the code. But if you have some coding knowledge and can see and understand what needs to change, then hopefully this will be a help to someone.
Cheers.