AD 脚本kixtart运用之六(outlook邮件批量生成签名)

基于上一编文章http://windyma.blog.51cto.com/661702/1967071里的设置

我们在Function.kix添加如下内容(备注:此outlook签名function来自网上,经过我比较大的修改):

----------------

Function GenerateOutlookSig($SignatureFileName)

$EmailAccountName = @WUSERID

;----获取outlook配置profile名字(如果有多个profile名字的话,只会取第一个)

If KeyExist("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles")

$ENUMKEY = "HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"

Endif

If KeyExist("HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles")

$ENUMKEY = "HKCU\Software\Microsoft\Office\15.0\Outlook\Profiles"

EndIf

$ProfileName = ENUMKEY("$ENUMKEY", 0)

$ENUMKEY = "$ENUMKEY\$ProfileName\9375CFF0413111d3B88A00104B2A6676"

$hexEmailAccountName = OutlookHexConvert($EmailAccountName)

$hexSignatureFileName = OutlookHexConvert($SignatureFileName)

$KeyNumber = "00000001"

While $KeyNumber <> "" and $MatchFound <> True

$KeyNumber = ENUMKEY("$ENUMKEY", $Index)

$subIndex = 0

While @ERROR = 0 and $subMatchFound <> True

$ValueName=ENUMVALUE("$ENUMKEY\$KeyNumber", $subIndex)

If $ValueName = "New Signature"

$subMatchFound = True

EndIf

$subIndex = $subIndex +1

Loop

If $subMatchFound = "True"

$MatchFound = True

EndIf

$Index = $Index + 1

Loop

If $KeyNumber = ""

LogEvent(1, 0, "Email account $EmailAccountName was not found for user @WUSERID. Aborting signature update.", , "KiXtart")

$GenerateOutlookSig = False

Exit

EndIf

;----从域系统获取用户信息

$objSysInfo = CreateObject("ADSystemInfo")

$strUser = $objSysInfo.UserName

$objUser = GetObject("LDAP://" + $strUser)

$strName = $objUser.givenName + " " + $objUser.sn

$strJob = $objUser.title

$strEmail = $objUser.mail

$strMobile = $objUser.mobile

If $strCompany = "" $strCompany = $objUser.company EndIf

If $strPhone = "" $strPhone = $objUser.telephoneNumber EndIf

If $strFax = "" $strFax = $objUser.facsimiletelephonenumber  EndIf

If $strWebsite = "" $strWebsite = $objUser.wWWHomePage EndIf

;----生成签名HTML文件的内容

$HTMLdata=‘<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><META content="text/html; charset=gb2312" http-equiv=Content-Type>‘

$HTMLdata=$HTMLdata + ‘<META name=GENERATOR content="MSHTML 11.00.10570.1001"></HEAD><BODY><DIV><FONT size=2 face=Arial><STRONG>Kind regards,</STRONG> <BR><BR></FONT>‘

$HTMLdata=$HTMLdata + ‘<TABLE style="HEIGHT: 167px; WIDTH: 460px; MARGIN-TOP: 0px" cellSpacing=0 cellPadding=0 width=460 border=0>‘

$HTMLdata=$HTMLdata + ‘<TR><TD style="PADDING-BOTTOM: 5px; PADDING-RIGHT: 5px" vAlign=top width=85 noWrap align=left><FONT size=2 face=Arial>‘

$HTMLdata=$HTMLdata + ‘<IMG style="HEIGHT: 80px; WIDTH: 80px" border=0 hspace=0 src="http://www.neo-concept.com.cn/mail-logo.jpg" width=80 align=baseline height=80></FONT>‘

$HTMLdata=$HTMLdata + ‘</TD><TD vAlign=top noWrap align=left><FONT color=#000000 size=2 face="Trebuchet MS">‘ + $strName + ‘<BR><STRONG>‘ + $strCompany + ‘</STRONG>‘

$HTMLdata=$HTMLdata + ‘<BR>Tel: ‘ + $strPhone + ‘<BR>Fax: ‘+ $strFax

if  $strMobile <> "" $HTMLdata=$HTMLdata + ‘<BR>Mobile: ‘+ $strMobile ENDIF

$HTMLdata=$HTMLdata + ‘<BR>Internet: <A style="TEXT-DECORATION: none" href="‘ + $strWebsite + ‘" ><FONT color=#000000 >‘+ $strWebsite  + ‘</FONT></A></FONT></TD></TR><TR>‘

$HTMLdata=$HTMLdata + ‘<TD vAlign=top colSpan=2 noWrap align=left><HR color=#ffcc00 SIZE=1 style="HEIGHT: 1px; WIDTH: 460px">‘

$HTMLdata=$HTMLdata + ‘<FONT color=#000000 size=1 face="Trebuchet MS">The content of this e-mail is intended solely for the use of the Individual or entity to whom it is<BR>‘

$HTMLdata=$HTMLdata + ‘addressed. If you have received this communication in error, be aware that forwarding it,copying<BR>it, or in any way disclosing its content to any other person, ‘

$HTMLdata=$HTMLdata + ‘is strictly prohibited. If you have<BR>received this communication in error, please notify the author by replying to this e-mail immediately.</FONT></TD></TR></TABLE></DIV></BODY></HTML>‘

;----生成签名HTML文件(先将删除旧的同名文件)

$ffh=FreeFileHandle()

If NOT Exist("%appdata%\Microsoft\Signatures") MD "%appdata%\Microsoft\Signatures" EndIf

If Exist("%appdata%\Microsoft\Signatures\$SignatureFileName.htm") Del "%appdata%\Microsoft\Signatures\$SignatureFileName.htm" EndIf

If @ERROR = 0

$htmlFile=open($ffh,"%appdata%\Microsoft\Signatures\$SignatureFileName.htm",5)

$htmlFile=writeline($ffh,$HTMLdata)

$htmlFile=close($ffh)

Else

$SigGenFailed = True

EndIf

;---生成签名text文件的内容

$PLAINdata=‘Kind regards,‘[email protected]

[email protected]

[email protected]

$PLAINdata=$PLAINdata+‘Tel: ‘ + [email protected]

$PLAINdata=$PLAINdata+‘Fax: ‘+ [email protected]

if  $strMobile $PLAINdata=$PLAINdata+‘Mobile: ‘ + $strMobile [email protected] ENDIF

$PLAINdata=$PLAINdata+‘Internet: ‘ + $strWebsite [email protected][email protected]

If $strDisclaimer

$strDisclaimerExpanded = Split($strDisclaimer, "<br>")

For Each $line in $strDisclaimerExpanded

[email protected]

Next

[email protected]

EndIf

;----生成签名text文件(先将删除旧的同名文件)

$ffh=FreeFileHandle()

If Exist("%appdata%\Microsoft\Signatures\$SignatureFileName.txt") Del "%appdata%\Microsoft\Signatures\$SignatureFileName.txt" EndIf

If @ERROR = 0

$plainFile=open($ffh,"%appdata%\Microsoft\Signatures\$SignatureFileName.txt",5)

$plainFile=writeline($ffh,$PLAINdata)

$plainFile=close($ffh)

Else

$SigGenFailed = True

EndIf

;---将签名应用到新建、转发、回复

If NOT $SigGenFailed = True AND Exist("%appdata%\Microsoft\Signatures\$SignatureFileName.htm") AND Exist("%appdata%\Microsoft\Signatures\$SignatureFileName.txt")

WriteValue("$ENUMKEY\$KeyNumber", "New Signature", $hexSignatureFileName, "REG_BINARY")

WriteValue("$ENUMKEY\$KeyNumber", "Reply-Forward Signature", $hexSignatureFileName, "REG_BINARY")

If @ERROR = 0

LogEvent(0, 0, "Outlook signature files and serial for account $EmailAccountName successfully updated to version $Serial for @WUSERID.", , "KiXtart")

$GenerateOutlookSig = True

Else

LogEvent(2, 0, "Failed to update Outlook signature serial for user @WUSERID!", , "KiXtart")

$GenerateOutlookSig = False

EndIf

Else

LogEvent(2, 0, "Failed to generate and/or write new signature files for user @WUSERID!", , "KiXtart")

$GenerateOutlookSig = False

EndIf

EndFunction

Function OutlookHexConvert($strInput)

$strInput = TxtToHex($strInput)

While $strInput <> ""

$OutlookHexConvert = $OutlookHexConvert + Left($strInput, 2) + "00"

$strInput = Right($strInput, Len($strInput) - 2)

Loop

$OutlookHexConvert = $OutlookHexConvert + "0000"

EndFunction

Function TxtToHex($strInput)

While $strInput <> ""

$char = Left($strInput, 1)

$ASCIIVal = asc($char)

$HexVal = $HexVal + DecToHex($ASCIIVal)

$TxtToHex = $TxtToHex + DecToHex($ASCIIVal)

$strInput = Right($strInput, Len($strInput) - 1)

Loop

EndFunction

到此在kixtart.kix里加入调用脚本,如下内容即: GenerateOutlookSig(neo123)

另外因为在线编辑的问题,原本一行代码造成N多换行,现我把原文件上传上来

下载地址:http://down.51cto.com/data/2336538

时间: 2024-10-21 03:07:25

AD 脚本kixtart运用之六(outlook邮件批量生成签名)的相关文章

AD 脚本kixtart运用之三(添加windows共享打印机)

在http://windyma.blog.51cto.com/661702/1967027文章,已做好用户脚本基础上 在脚本文件kixtart.kix里添加如下内容: --------------------------------------- IF INGROUP ("Color_Printer") If AddPrinterConnection ("\\zsprinter.nccn.int\NEO-Color-Printer") = 0 ? "Add

AD 脚本kixtart运用之一 ( 网络盘自动映射)

首先我们在Active Directory 用户和计算机工具中,在用户的配置文件下的登陆脚本里输入如下 然后我们在域共享\\nccn.int\NETLOGON\ 下新建一个NEO.bat的文件内容如下 -------------------------------------------- @echo off cmd /c %logonserver%\netlogon\KIX32.EXE %logonserver%\netlogon\kixtart.kix exit --------------

AD 脚本kixtart运用之四(用户桌面背景)

在http://windyma.blog.51cto.com/661702/1967027文章,已做好用户脚本基础上进行设置 首先设置用户背景桌面是微软件的Bginfo工具,而kixtart只是用来获取用户屏幕的分辨率,根据不同屏幕的分辨率再来调用Bginfo工具来设置不同分辨率的背景图片,以此保证图片不会变形. 第一,在域\\nccn.int\NETLOGON 共享下新建Bginfo目录,把Bginfo.exe工具及不同分辨率的背景图全复制到Bginfo目录下. 第二,用Bginfo.exe工

AD 脚本kixtart运用之五(用户电脑屏保设置)

原理和设置基前一编http://windyma.blog.51cto.com/661702/1967071一样 只需要在kixtart.kix中添加如下内容 ------------------------------ IF EXIST ("%userprofile%\$ScreenRes.scr") WriteValue("HKEY_CURRENT_USER\Control Panel\Desktop", "SCRNSAVE.EXE", &qu

邮件批量发送

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using System.Net.Mail;using System.Configuration;using System.Collections;using System.Data.SqlClient;public partial

shell脚本批量生成配置文件

如果管理的站点和服务器较多的情况下,每次修改配置文件都相当痛苦.因而想到了用shell脚本来批量生成配置文件和配置数据.下面这个脚本是为了批量生成nagios监控配置文件的一个shell脚本程序.其原理是事先定义一个shell脚本模板,然后每个需要监控的站点复制一份模板替换掉模板文件里面的变量. 1.准备模板文件webcheck.template more webcheck.template ###################WEBURL define start##############

linux shell脚本检测硬盘磁盘空间 邮件报警

使用 http://www.weiruoyu.cn/?p=368 shell脚本监控硬盘空间剩余空间 邮件报警 1.先观察一下磁盘,和如何使用脚本 [[email protected] ~]# df -h 文件系统              容量  已用 可用 已用% 挂载点 /dev/mapper/VolGroup00-LogVol00 8.9G  2.6G  5.9G  31% / /dev/sda1              99M   13M   82M  13% /boot tmpfs

shell 脚本实战笔记(9)--linux自动批量添加用户

前言: 添加linux用户帐号,这个相对简单, 在面对集群, 许多机器的时候, 我们该如何去做和实现? 这篇短文, 简单讲解一些思路, 尽可能地涉及周边的一些知识点. 不光是运维人员会面临这个问题, 对一个基于linux平台的集群服务或软件(比如hadoop集群), 有时也会涉及到这块. 应用场景: 是以centos 6.4作为演示的系统, 其他的系统有类同, 也有差异, 且以实战演练, 一步步的讲述下流程. *) 实战演练 查阅useradd的使用和参数选项useradd --help -d,

如何更改outlook邮件附件的默认保存地址

outlook附件默认的保存地址是"我的文档",而我习惯将我邮件的附件保存在桌面上,每次保存时都得多点一下鼠标,为了提高工作效率,通过上网搜索和自己摸索,找到了更改outlook邮件附件的默认保存地址的办法,总结如下. 1.单击"开始",然后单击"运行". 2.在"打开"框中,键入 regedit,然后按 Enter 键. 3.在注册表编辑器中,找到注册表中的以下子项: HKEY_CURRENT USER\Software\M