;; ;;=====================================================================================----- ;; ;;FUNCTION OutlookSignature() ;; ;;ACTION Sets/Retrieves the Outlook signature for the defined/default profile & account ;; ;;AUTHOR Glenn Barnas ;; ;;VERSION 1.1 - 2009/07/02 ;; ;;HISTORY 1.0 - 2008/10/05 - initial release ;; 1.1 - 2009/07/02 - update to specify the mail account by email address ;; ;;SYNTAX OutlookSignature([SigName] [, Profile] [, NewReply]) ;; ;;PARAMETERS SigName - OPTIONAL - String ;; - File name of the signature to set. File must exist in the proper ;; folder - no checks are made in this UDF. ;; ;; Profile - OPTIONAL - String ;; - The name of the profile to set. If not specified, the default profile ;; is determined and used. The account within the profile can be specified ;; as "PROFILE_NAME:userid@domain.com", otherwise the primary account will ;; be used. ;; ;; NewReply - OPTIONAL, a binary value used to define which mail types ;; will receive the signature. Values are cumulative. ;; 1 = New Messages (default) ;; 2 = Reply/Forward messages ;; 4 = Delete the New, Reply, or Both settings. ;; Must be used with 1 or 2! ;; Valid DELETE values are 5 (new), 6 (reply) or 7 (both). ;; ;;REMARKS Used to read, set, or delete the default outlook signature. The ;; signature for new messages and reply/forward messages can be set ;; and deleted independently. The AtoU and UtoA UDFs perform simple ;; translation between ASCII and Unicode. ;; ;;RETURNS CSV list of signature settings if SigName is null. ;; Data is returned as ProfileName,New Signature,Reply-Forward Signature. ;; If write or delete function is selected, returns TRUE on success, ;; FALSE on failure. ;; ;;DEPENDENCIES AtoU() & UtoA UDFs, Outlook ;; ;;TESTED WITH W2K, WXP, W2K3, Vista, Outlook 2003 & 2007 ;; ;;EXAMPLES ' Set New: ' ;; OutlookSignature('AutoSignature') ? ; set to "autosignature" ;; ' Read: ' ;; OutlookSignature() ? ; read setting ;; ;; ' Set Reply: ' ;; OutlookSignature('ReplySignature',,2) ? ; set to "replysignature" ;; ' Read: ' ;; OutlookSignature() ? ; read setting ;; ;; ' Delete New: ' ;; OutlookSignature('','',5) ? ; delete setting ;; ' Read: ' ;; OutlookSignature() ? ; read setting ;; ;; ' Delete Reply: ' ;; OutlookSignature('','',6) ? ; delete setting ;; ' Read: ' ;; OutlookSignature() ? ; read setting ; Function OutlookSignature(OPTIONAL $_strSigName, OPTIONAL $_strProfile, OPTIONAL $_binNewReply) Dim $_, $_Tmp ; Temp vars Dim $_strKeyPath ; Registry Key Dim $_intIndex ; index pointer Dim $_strSubKey ; enumerated subkey Dim $_strSubKeyPath ; constructed key path Dim $_strResult ; data to be returned Dim $_strAcctAddr ; email account string Dim $_Process ; flag is true when record should be processed $_strKeyPath = 'HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\' ; get default profile name if none specified If $_strProfile = '' $_strProfile = ReadValue($_strKeyPath, 'DefaultProfile') Else ; if profile was specified.. If InStr($_strProfile, ':') ; see if account email was, too $_ = Split($_strProfile, ':') ; and separate the profile and mail account IDs $_strProfile = $_[0] $_strAcctAddr = $_[1] EndIf EndIf ; If the NewReply value is empty, set it to the default If Val($_binNewReply) = 0 $_binNewReply = 1 ; set default to New Message EndIf ; If the sig file name is null and the DELETE bit is not set, perform a READ operation If $_strSigName = '' And $_binNewReply < 5 $_binNewReply = 0 ; set value to force READ EndIf ; build byte-array from signature name $_strSigName = AtoU($_strSigName) $_strKeyPath = $_strKeyPath + $_strProfile + "\9375CFF0413111d3B88A00104B2A6676" $_intIndex = 0 $_strSubKey = EnumKey($_strKeyPath, $_intIndex) While Not @ERROR $_strSubKeyPath = $_strKeyPath + "\" + $_strSubKey $_Process = 0 ; Subkey 2 is the primary account - process this subkey if the ; value is 2 and no account address was specified If Val($_strSubKey) = 2 And Not $_strAcctAddr $_Process = 1 EndIf ; Compare the defined account address with the email value in the subkey ; Process this subkey if they match If $_strAcctAddr = UtoA(ReadValue($_strSubKeyPath, 'Email')) $_Process = 1 EndIf If $_Process ; process this key If $_binNewReply & 4 ; Delete operations If $_binNewReply & 1 ; delete New Message setting $_ = DelValue($_strSubKeyPath, 'New Signature') $_strResult = cStr(Not @ERROR) EndIf If $_binNewReply & 2 ; delete Reply/Forward setting $_ = DelValue($_strSubKeyPath, 'Reply-Forward Signature') $_strResult = cStr(Not @ERROR) EndIf Else ; read/write operations If $_binNewReply = 0 ; read the value $_strResult = $_strProfile + ',' + UtoA(ReadValue($_strSubKeyPath, 'New Signature')) + ',' + UtoA(ReadValue($_strSubKeyPath, 'Reply-Forward Signature')) EndIf If $_binNewReply & 1 ; update New Message setting $_ = WriteValue($_strSubKeyPath, 'New Signature', $_strSigName, 'REG_BINARY') $_strResult = cStr(Not @ERROR) EndIf If $_binNewReply & 2 ; update Reply/Forward setting $_ = WriteValue($_strSubKeyPath, 'Reply-Forward Signature', $_strSigName, 'REG_BINARY') $_strResult = cStr(Not @ERROR) EndIf EndIf ; read/write/delete EndIf ; subkey=2 $_intIndex = $_intIndex + 1 $_strSubKey = EnumKey($_strKeyPath, $_intIndex) Loop $OutlookSignature = IIf($_strResult, $_StrResult, 'fail') Exit 0 EndFunction