<?xml version="1.0" standalone="yes" ?><script uid="{34A99E5D-1607-4BD1-BD9F-899AC300092B}" shared="f" desc="Multiple Signatures" help="Multiple signatures" imglib="netware.dli" imgid="116" fav="f" inten="t" vbe="f" created="20010403T143312" smod="20030905T154348" pmod="20030905T151422" lfdn="" rm="t" ver="" author="Advansys Pty Limited (c) Copyright 2003" amail="formativ@advansyscorp.com" aurl="www.advansyscorp.com" acom="" aphone="+61 2 9968 2991" comex="f" dxwrn="f" minver="" cats=""><integrations><integration type="ngw_toolbar" context="GW.MESSAGE.MAIL" event="" seq="0" otherid="" menu="" before="" anchor="an_under"></integration></integrations><classes></classes><source><primary><![CDATA['-------------------------------------------------------------------------------
' Formativ Business Solutions
' Multiple Signature Manager
' Version 1.6
' 
' This applet lets you select from a list of user-definable signatures, and
' insert the signature into a message.  The signatures are plain text or HTML files
' found at the location specified by the SIGNATURE_LOCATION constant.  They 
' should be given a descriptive name and have a file extension of:
'
' .sig - if the file is a plain text file; or
' .hts - if the file is an HTML file
'
' Note on creating HTML signature files with an external HTML editor for use
' with this applet:
' Always use fully qualified path names (file:///c:/images/graphic.gif) or URLs
' (http://www.advansyscorp.com/advheader.gif) for image files and URLs (web pages
' etc.).  If you don't do this, the HTML signature will not appear nor link correctly
' within the GroupWise HTML message.  Do NOT use relative paths, i.e. /images/graphic.gif.
'
' If the message view is HTML then both the Sig (Text file) and HTS (HTML) files
' are displayed in the selection list box. If the message view is plain text then
' the applet will display only SIG files for selection. 
'
' The last signature selected is remembered by saving the selection in a file. When
' this applet runs, the last signature will be highlighted automatically. The end user
' can disable/enable this option by setting the variable SAVE_LAST_SIGNATURE to 
' TRUE or FALSE.
'
' Integrations:
' For optimal results, this applet should be assigned to the email OnReply and 
' OnCompose events.  You can also run the applet from the Mail toolbar or any
' other message type with which you wish to integrate.   
'
' Note: If you use this multiple signature applet regularly, you can create a separate 
' folder for all signature files and specify the folder path below. 
'
' INTEGRATION: Suggested integrations are the Mail toolbar, OnCompose and OnReply events.
' You can also integrate with any other message type, such as appointment, note, task etc..
' 
' History:
' 14 December 01 - MA,GB: Version 1.5 Multiple Signature release 
'
'-------------------------------------------------------------------------------
'-->Flexalock
'-------------------------------------------------------------------------------
' History:
' 14 December   01 - MA,GB: Version 1.5 Multiple Signature release
' 05 September  03  - MA: Bug fixed - GetFileExtension() function added to replace the file type 
' property. Applet used to get the file type property and determine the file to
' display in the dialog. File type property are user-defined. If the user change the 
' file type to different type, applet will not display the file in the dialog. 
'-------------------------------------------------------------------------------


Const CAPTION                   = "Formativ Business Solutions "
const IDS_FSO_ERR					      = "Failed to create the file system object.  Please contact your system administrator."

Dim FSO
Dim Dlg

Const HTM_FILE                  = "HTS"
Const SIG_FILE                  = "SIG"
Const SAVE_LAST_SIGNATURE       = TRUE


' Full path to the location of the signature files
SIGNATURE_LOCATION = Utilities.GetDataDirectory 
FILE_NAME = SIGNATURE_LOCATION + "ADV_MultipleSignature.ol"


'-------------------------------------------------------------------------------
' Display the signature selection dialog.  If the user selects a signature,
' insert it into the message.  We check the calling event, supplied in the
' mandatory GWEvent parameter, to determine where the signature should be
' inserted. 
'-------------------------------------------------------------------------------
Sub Main(Client, GWEvent)

  Dim SigFile
  
  On Error Resume Next
    
  Set FSO = CreateObject("Scripting.FileSystemObject")  
  
  if FSO is nothing then
    call msgbox(IDS_FSO_ERR, vbCritical, CAPTION)
    exit sub  
  end if
  
  
  'Perform the action based on the event integrations
  If (GWEvent = "GW#C#REPLY") Then
  
    ' Get the signature file to retrieve  
    SigFile = GetSignatureFile()
    
    ' Make sure the file exists    
    If FSO.FileExists(SigFile) Then    
      RetrieveToTop(SigFile)   
    End If
    
  Else
  
    'Any other event check whether we have a composing item to add signature
    If not ValidMsg() Then    
      Call MsgBox("No GroupWise message was found for signature insertion.", vbExclamation, CAPTION)
      exit sub    
    end if
    
    ' Get the signature file to retrieve
    SigFile = GetSignatureFile()
    
    ' Make sure the file exists
    If FSO.FileExists(SigFile) Then    
      Call GroupWise.Retrieve(SigFile)  
    End If
    
         
  End If   

  Set FSO = Nothing    
  
End Sub




'-------------------------------------------------------------------------------
' Get signature file
'-------------------------------------------------------------------------------
Function GetSignatureFile()

  Dim Cmd
  Dim LBCtl  
  Dim FileList
  
  GetSignatureFile = ""
  Set FileList = Utilities.StringList
  
  cExit = 999  
  cIntro = 101
  cFileSelected = 103
  Cmd = cIntro
    
  ExtractSignatureFiles(FileList)  
  Call SetupDlg(LBCtl, FileList)
          
  Do While Cmd <> cExit  
  
    ' Display the dialog
    If Cmd = cIntro Then
      Select Case Dlg.Execute
        Case Btn1 Cmd = cFileSelected
        Case Else Cmd = cExit
      End Select
    End If
       
    
    ' Is any signature selected?
    If Cmd = cFileSelected Then
      Cmd = cIntro    

      If (LBCtl.Selected = "") Then
        Call MsgBox("Select a signature file to continue.", vbInformation, CAPTION)
      Else

        sIndex = LBCtl.Items.IndexOf(LBCtl.Selected)
        If (sIndex <> - 1) Then
          GetSignatureFile = LBCtl.Items.Objects(sIndex)
          Cmd = cExit
          
          ' Save the settings
          If SAVE_LAST_SIGNATURE Then
            Call Utilities.SaveStringToFile(LBCtl.Selected, FILE_NAME, TRUE)
          End If
          
        End If   

      End If
      
    End If
    
    
  Loop
  
  Set FileList = Nothing
  
End Function




'-------------------------------------------------------------------------------
' Retrieve the file to top
'-------------------------------------------------------------------------------
Sub RetrieveToTop(SigFile)       

  Call GroupWise.FocusSet(fcsMessage, "")
  Call GroupWise.PosTextTop
  Call GroupWise.Retrieve(SigFile)       
  Call GroupWise.PosTextTop
  
End Sub



'-------------------------------------------------------------------------------
' Get the last signature from the file 
'-------------------------------------------------------------------------------
Function GetLastSignature

  If FSO.FileExists(FILE_NAME) Then
    GetLastSignature = Trim(Utilities.LoadStringFromFile(FILE_NAME))
  End If

End Function




'-------------------------------------------------------------------------------
' Do we have a composing item available?
'-------------------------------------------------------------------------------
Function ValidMsg()
  
  ValidMsg = FALSE
  
  Dim iMsg
  
  On Error Resume Next
  Set iMsg = GroupWise.ComposingItem

  If not iMsg Is Nothing Then
    ValidMsg = TRUE
  End If

  Set iMsg = Nothing
  
End Function



'-------------------------------------------------------------------------------
' Extract the signature files in a string list
'-------------------------------------------------------------------------------
Function ExtractSignatureFiles(aFileList)

  Dim fileObj
  Dim filesObj
  Dim File_Type
  dim iFileExt

  On Error Resume Next
    
  aFileList.clear
  
  Set filesObj = FSO.GetFolder(SIGNATURE_LOCATION)  
  
  if filesObj is nothing then
    exit function
  end if
  
  Set fileObj = filesObj.Files
  
  if fileObj is nothing then
    exit function
  end if
    
  ' Is the message view is plain text, then only load the SIG file
  If (GroupWise.EnvEditorStyle = 1) Then
    
    For Each file in fileObj
      If (GetFileExtension(file.name) = SIG_FILE) Then
        Call aFileList.AddObject(FormatFileName(file.Name), file.path) 
      End If
    Next
       
  Else
    
    ' Load the SIG and HTS file if the view is html
    For Each file in fileObj
      iFileExt = GetFileExtension(file.name)
              
      If (iFileExt = SIG_FILE) Or (iFileExt = HTM_FILE) Then
        Call aFileList.AddObject(FormatFileName(file.Name), file.path) 
      End If

    Next   
    
  End If
  
  Set fileObj = Nothing
  Set filesObj = Nothing
    
End Function




'-------------------------------------------------------------------------------
' Format the file name
'-------------------------------------------------------------------------------
Function FormatFileName(sName)
  
  dim iPos
  dim iFileName
  dim iFileExt
  
  FormatFileName = sName
  
  iPos = InstrRev(sName, ".", -1, 1)
  if (iPos = 0) then
    exit function    
  end if
  
  iFileName = mid(sName, 1, iPos -1)
  iFileExt = mid(sName, iPos + 1)
  
  
  If (UCase(iFileExt) = HTM_FILE) Then
    FormatFileName = iFileName & " [HTML]"
  Else
    FormatFileName = iFileName  
  End If
  
End Function



'-------------------------------------------------------------------------------
' Get the file extension from the file path
'-------------------------------------------------------------------------------
function GetFileExtension(aPath)

  GetFileExtension = ""
  aPath = trim(aPath)
  
  if (len(aPath) = 0) then
    exit function
  end if
  
  dim iPos
  
  iPos = InstrRev(aPath, ".", -1, 1)

  if (iPos = 0) then
    exit function
  end if
  
  GetFileExtension = UCASE(mid(aPath, iPos + 1))
  
end function




'-------------------------------------------------------------------------------
' Display the available signatures in the list box
'-------------------------------------------------------------------------------
Function SetupDlg(LBCtl, FileList)

  Set Dlg = Utilities.NewControlBoxDialog
  With Dlg
    .Height = 250
    .Caption = CAPTION    
    .Title = "Select a signature"      
  End With
  
  
  'Display files in list box  
  Set LBCtl = Dlg.AddListBoxControl
  With LBCtl
    .Height = 135
    .MultiSelect = FALSE
    .Hint = "Select the signature you wish to use"
    For x = 0 to FileList.Count -1
      .Items.AddObject FileList.Strings(x), FileList.Objects(x) 
    Next 
    .Sorted = TRUE
    
    If SAVE_LAST_SIGNATURE Then 
      .Selected = GetLastSignature 
    End If
    
  End With
   
   
  'This panel is included to force the ListBox control to observe its height property.
  Set Pnl = Dlg.AddPanelControl
  With Pnl
    .Height = 0
    .AutoSpace = FALSE
  End With
     
End Function

]]></primary><backup/></source></script>