On Thu, 23 Nov 2006 at 22:10:16 +0100, Richard wrote: RA>> If you want more information, I can provide you with the QTs I have RA>> that use this. > > Reg ex is way above my head but your way seems a pretty neat solution > and it would be good to try. I don't suppose you could post them here > could you or would that annoy the majority of people who have no > interest in them. If you think that's not a good idea I'd certainly > appreciate a PM with them if you feel like sharing all your hard work > amongst us lesser mortals! ;-)
Okay, here goes. First of all, all your signatures will be stored in their own quick templates (QTs). Create a default signature QT called DefaultSig. This will be the one used if you don't need a special purpose signature for someone. Then the special purpose signature QTs should be given names like WorkSig or PersonalSig or ProjectSig. When you need a special purpose signature for a particular recipient, include in the memo area of their address book entry (i.e. on the "Other" tag) <sig>Project</sig> That will be combined with the letters "Sig" to give the signature QT name required (ProjectSig in this case). So far so good?? Now you will need to create quick templates that do the work by copying the QT contents below and putting that into appropriately named QTs in your system. There are three of them. Include the following line in your message template %Qinclude="setsig"%- I have set up this system so that it works properly when I have multiple recipients for an email. So if I am sending an email to a team working on a particular project, it will use the special purpose signature that I use for that project. However, if I have a mixture of recipients, only some of whom are on that project team, it will use my default signature file, because the special purpose one is not appropriate for most of the recipients. This is done by the Setsig QT. The Setsig QT (below) looks at the *entire list* of recipients, including CC'd recipients, and looks for specific (non-default) signatures in each recipient. If it finds the same specific signature for more than 50% of the recipients, it will use that, otherwise it will use the default signature (i.e. the DefaultSig QT). Setsig actually just sets up the list of recipients and identifies the appropriate signature. It calls another quick template called FindSigToken that determines whether there is a special purpose sig file required. Note that these QTs are (sort of) self-documenting, so there is a lot of explanation at the beginning that you can read if you are so inclined. ---- [ Start SetSig Quick Template ] ---- %REM=^%- Set signature according to tokens in the recipient's memo field. A token is identified by a line of the form: <sig>XXX</sig> If only one signature token exists in the recipient group, and a majority of recipients has the signature token, the XXXSig is used. Otherwise the default signature (DefaultSig) is used. %_SetSig_Text stores the original list of recipients %_SetSig_Temp stores the list of recipients yet to be processed %_SetSig_Name is set to the sig token if exactly one exists in the recipient group %_SetSig_No is the number of recipients with the single sig token %_SetSig_Total is the total number of recipients %_SetSig_Token stores the token identified for use %_SetSig_TmpTkn is a temporary token store %_SetSig_Type is a flag taking the following values: 0: no signature token found 1: one signature token found 2: multiple signature tokens found^%- %- %rem=^ Initialise variables^%- %_SetSig_Type=0%- %_SetSig_Total=0%- %_SetSig_No=0%- %_SetSig_Text="%ToList"%- %_SetSig_Temp="%_SetSig_Text,%CCList"%- %_SetSig_Name="default"%- %- %rem=^ Find Signature Token^%- %QInclude("FindSigToken")%- %If:'%_SetSig_Type'='1'%- :'%IfN:^%_SetSig_No^<^%Calculate(#%_SetSig_Total/2#)^%- :^%_SigQT="DefaultSig"^:^%_SigQT="%_SetSig_Token%-Sig"^'%- :'%_SigQT="DefaultSig"'%- %QInclude(%_SigQT)%- %SetHeader("To","%_SetSig_Text")%- ----- [ End Setsig Quick Template] ----- Here is the FindSigToken QT that works through the list of recipients and determines the special signature if it exists. It calls another QT called Get_Memo_Attribute that actually looks into the address book entry for the special signature name. ---- [ Start FindSigToken Quick Template ] ---- %REM=^%- This is a recursive QT that parses the list of recipients and returns: * the first sig token found, * the total number with that token and * a flag identifying whether that was the only sig token found^%- %- %- %If:'%setpattregexp="@"%regexpmatch="%_SetSig_Temp"'<>''%- :'%setpattregexp="(?i)^((?:.*?)@(?:.*?))(?:,|;)\s*(.*)?"%- %regexpblindmatch="%_SetSig_Temp,"%- %SetHeader(+To+,+%subpatt="1"+)%- %_SetSig_Temp=+%Subpatt="2"+%- %_SetSig_Total=%Calculate("%_SetSig_Total+1")%- %_SetSig_TmpTkn=+%QInclude(Get_Memo_Attribute,"sig","")+%- %If:"%_SetSig_TmpTkn"<>""%- :"%- %_SetSig_Type=1%- %_SetSig_No=%Calculate(^%_SetSig_no + 1^)%- %If:^%_SetSig_Token^=^^%- :^%_SetSig_Token=%_SetSig_TmpTkn^%- :^%If:&%_SetSig_Token&<>&%_SetSig_TmpTkn&:&%_SetSig_Type=2&:%-:^"%- :""%- %QInclude("FindSigToken")'%- :''%- ----- [ End FindSigToken Quick Template ] ----- And this is the Get_Memo_Attribute QT that looks into the address book entry. ---- [ Start Get_Memo_Attribute Quick Template ] ---- %Rem=' Usage: <attribute value>=%QInclude(Get_Memo_Attribute,"Tag","Default_Value") '%- %If:'%SetPattRegExp="(?im)^<%_1"%RegExpMatch="%ABToMemo"'='':'%_2'%- :'%If:+%SetPattRegExp="(?im)^(<%_1/>)"%RegExpMatch="%ABToMemo"+<>++:++%- :+%SetPattRegExp="(?im)^(?:<%_1>)(.*?)(?:</%_1>)"%RegExpMatch="%ABToMemo"+'%- ----- [ End Get_Memo_Attribute Quick Template ] ----- So, set up the three quick templates shown above, set up signature QTs, one called DefaultSig (I actually have a different DefaultSig for each account) and others called, for example, WorkSig, PersonalSig, Project1Sig, Project2Sig, etc. Then put <sig>Project1</sig> into the memo ("Other") area in someone's address book entry and try it out. It should then work! But of course if it /*doesn't*/ work get back to me and I will look more closely to see if I have omitted any instructions. -- Robin Using The Bat! v3.85.03 Windows XP 5.1 Build 2600 Service Pack 2 Popfile v0.22.4 ________________________________________________ Current version is 3.85.03 | 'Using TBUDL' information: http://www.silverstones.com/thebat/TBUDLInfo.html