自动化配置OutlookExpress邮件客户端
来源:优易学  2011-2-9 13:23:05   【优易学:中国教育考试门户网】   资料下载   IT书店

  在部署一个政府OA系统中的邮件模块时,由于用户全都是五六十岁的老人,邮件客户端统一采用Outlook Express,甲方项目经理要求邮件客户端的配置实现全自动化,非常头疼,好不容易才解决,来此与大家分享。
  输入分析:
  要配置邮件客户端,以下几个输入是必须由用户来完成的:
  1.用户名,即PREFIX,@之前的内容
  2.域
  3.输入密码
  存储分析:
  用户输入数据的存储位置如下:
  1.用户名——存于注册表(明文)
  2.域——存于注册表(明文)
  3.输入密码——存于注册表(密文)
  技术选取:
  有了以上两步需求,接下来就开始技术选择。由于必须访问注册表,所以排除所有的web技术,ActiveX成本较高,也排除
  .NET Winform应用程序配置麻烦,排除
  VB/VC应用程序配置较简单,但不如VBScript轻量
  VBScript可以通过shell object来访问注册表
  VBScript可双击直接运行,无需特别定制界面
  综上分析,故选用VBScript来进行配置。
  代码:
  代码如下,参照了华盛顿市府的配置解决方案:
  setoShell=wscript.CreateObject("Wscript.Shell")
  Functionmain()
  dimusername,domain
  username=inputbox("EnteryourEmailPREFIXorUSERNAME(BEFOREthe@signbutNOTincludingthe@sign)","OutlookExpressProfileCreator","Username")
  Ifusername=""Then
  wscript.Quit(0)
  EndIf
  Ifusername="Username"Then
  whileusername="EnteryourEmailPREFIXorUSERNAME"
  username=inputbox("EnteryourEmailPREFIXorusername(beforethe@sign)","OutlookExpressProfileCreator","Username")
  Ifusername=""Then
  wscript.Quit(0)
  EndIf
  wend
  EndIf
  domain=inputbox("EnteryourDomain(AFTERthe@signbutNOTincludingthe@sign)","OutlookExpressProfileCreator","Domain")
  Ifdomain=""Then
  wscript.Quit(0)
  EndIf
  Ifdomain="Domain"Then
  whiledomain="EnterYourDomainnameHere"
  username=inputbox("EnteryourDomainname(AFTERthe@signbutNOTincludingthe@sign)","OutlookExpressProfileCreator","Domain")
  Ifdomain=""Then
  wscript.Quit(0)
  EndIf
  wend
  EndIf
  ’  username=Ltrim(fixme(username))
  ’  domain=fixme2(domain)
  ’EXAMPLESTRINGFORRTRIM
  ’  RTrim(string)
  callplaceMailSettings(username,domain)
  msgbox("OutlookExpressConfigurationComplete,pleasestartOutlookExpressandenteryourpasswordwhenprompted.")
  EndFunction
  FunctionregRead(regStr)
  regRead=oShell.RegRead(regStr)
  EndFunction
  FunctionregWrite(val1,val2,val3)
  oShell.RegWriteval1,val2,val3
  EndFunction
  FunctionregDelete(regStr)
  calloShell.RegDelete(regStr)
  EndFunction
  ’Functionfixme(strValue)
  ’  dimuserEntry
  ’  userEntry=split(strValue,"@")
  ’  fixme=userEntry(0)
  ’EndFunction
  ’Functionfixme2(strValue2)
  ’  dimuserEntryd
  ’  userEntryd=split(strValue2,"@")
  ’  fixme2=userEntryd(0)
  ’EndFunction
  ’EXAMPLESTRINGFORSPLIT
  ’  Split(expression[,delimiter])
  ’PlacenewsettingsforMail
  FunctionplaceMailSettings(theUsername,theDomain)
  OnErrorResumeNext
  dimnewAccountNum,numKeyStr
  dimusername,domain
  newAccountNum=regRead("HKCUSoftwareMicrosoftInternetAccountManagerAccountName")
  IfnewAccountNum=""Then
  newAccountNum="00000001"
  ElseIfnewAccountNum<9Then
  newAccountNum="0000000"&newAccountNum
  Else
  newAccountNum="000000"&newAccountNum
  EndIf

[1] [2] [3] [4] 下一页

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训