邮件服务器-邮件系统-邮件技术论坛(BBS)

标题: 自动配置OutLook2003账号 [打印本页]

作者: helloworm    时间: 2009-8-21 11:35
标题: 自动配置OutLook2003账号
当我们要为一大批用户配置邮箱的时候,那可是辛苦事啊,所以我在网上找了一篇关于自动配置邮箱的脚本,如果还有不知道的,希望能帮到你。(如果你不用下面这个脚本,还有另一个方法,就是利用微软给我们的一个工具Office 2003 resource kit这个部署工具,它也可以达到相同作用。它最后也是生成下面的PRF文件。我们可以运行
outlook.exe /importprf  d:\test.prf.)


、我们需要有一个Outlook配置文件(PRF文件),此配置文件的生成及具体参数请参考http://technet.microsoft.com/zh-cn/library/cc179062(TechNet.10).aspx
2、执行写好的脚本将配置文件导入并配置Outlook客户端即可(PRF配置文件需要与脚本在同一目录,并在脚本中指定PRF文件的名称)
3、脚本内容

'===================================================================
'
' VBScript Source File  
'
' NAME: Billy Fu
'
' AUTHOR: Outlook配置脚本-Outlook_Profile_Config
'
' DATE  : 2008/7/14
'
'
'===================================================================
ON ERROR RESUME NEXT
Const OFFICE11_PATH = "C:\Program Files\Microsoft Office\Office11"
Const OFFICE12_PATH = "C:\Program Files\Microsoft Office\Office12"
dim strUserName
dim intOfficeVer
dim strOfficePath
strUserName = ""
intOfficeVer = ""
strOfficePath = ""
strUserName = InputBox("请输入您在域中的用户帐号,格式如:BillyFu","Outlook配置脚本")  
If strUserName = "" Then
    Msgbox "取消Outlook配置!"
Else
    while intOfficeVer = ""
  intOfficeVer = InputBox("请输入您本机安装的Outlook版本号:2007或2003,其他版本不支持","Outlook配置脚本","2003")  
  if intOfficeVer = "" then
      Msgbox "Outlook 设置取消!"
      intOfficeVer = "error"
  else
      if intOfficeVer <> "2007" And intOfficeVer <> "2003" Then
    intOfficeVer = ""
      else
    if intOfficeVer = "2007" then
        strOfficePath = OFFICE12_PATH
    else
        strOfficePath = OFFICE11_PATH
    end if
    strOfficePath = InputBox("请确定您本机安装的Outlook路径","Outlook配置脚本",strOfficePath)  
    Call InstallOutlookProfile
      end if
  end if  
    Wend
End If

sub InstallOutlookProfile

    ModifyPRFFile
    Dim WshShell
    Set WshShell = Wscript.CreateObject("Wscript.Shell")
  
    Dim strPath
    strPath = WScript.ScriptFullName   
    strPath = Left(strPath, InstrRev(strPath, "\")) & "OutlookProfile1.PRF" '指定Outlook PRF 配置文件
  
    dim strCmd
    strCmd = """" & strOfficePath & "\outlook.exe"" /importprf """ & strPath & """"  
    WshShell.Run strCmd, 1, false
end sub
sub ModifyPRFFile
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0
   Dim strCon

   Dim fso, f1, f2, ts
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f1 = fso.GetFile("OutlookProfile.PRF") '设置从Outlook配置文件中读取信息
   Set ts = f1.OpenAsTextStream(ForReading, TristateUseDefault)
   strCon = ts.ReadAll
   ts.close
   strCon = Replace(strCon,"%UserName%",strUserName)

   fso.CreateTextFile "OutlookProfile1.PRF"   
   Set f2 = fso.GetFile("OutlookProfile1.PRF") '创建一个配置文件
   Set ts = f2.OpenAsTextStream(ForWriting, TristateUseDefault)
   ts.Write strCon
   ts.Close
end sub
sub Err
   if err <> 0 then
      Wscript.echo "Outlook配置脚本出错,自动退出!"
      Err.Clear
   end if
end sub

作者: bosco    时间: 2009-8-28 17:46
请问如何导出prf文件,谢谢。
作者: tdk    时间: 2009-8-28 22:33
学习了




欢迎光临 邮件服务器-邮件系统-邮件技术论坛(BBS) (http://bbs.5dmail.cn/) Powered by Discuz! X3.2