找回密码
 加入
搜索
查看: 5676|回复: 13

[AU3基础] 【已解决】au3如何获取outlook当前使用的pst的位置?

  [复制链接]
发表于 2011-1-17 20:28:33 | 显示全部楼层 |阅读模式
本帖最后由 wsfda 于 2011-5-7 18:16 编辑

各位大哥!小弟这里拜托大家了,请问au3如何获取outlook当前使用的pst的位置?请问可以使用注册表吗?还是有其他的方法,实在想不出,请大家帮帮忙吧?或者使用批处理行吗?
谢谢各位了!
 楼主| 发表于 2011-1-18 10:15:50 | 显示全部楼层
我在作品展览里面看见了一个大哥写的用户文件备份工具,但是不知道他怎么获取outlook邮件存储位置的,因为每个人的邮件储存位置可能不一样,有人改到D、E盘去了
发表于 2011-1-18 10:52:41 | 显示全部楼层
注册表吧,仅供参考。
发表于 2011-1-18 11:35:23 | 显示全部楼层
#include <Array.au3>

$asPSTPath = _GetPSTPath()

If IsArray($asPSTPath) Then _ArrayDisplay($asPSTPath)

Func _GetPSTPath()
    Local $sFolderSubString, $sPath, $asPathSearch, $sReturn
    Local $oOutlook = ObjCreate("Outlook.Application")
    Local $oNS = $oOutlook.GetNamespace("MAPI")

    If IsObj($oNS) Then
        For $objFolder In $oNS.Folders
            $sPath = ""
            For $i = 1 To StringLen($objFolder.StoreID) Step 2
                $sFolderSubString = StringMid($objFolder.StoreID, $i, 2)
                If $sFolderSubString <> "00" Then $sPath &= Chr(Dec($sFolderSubString))
            Next

            $asPathSearch = StringRegExp($sPath, "(?i)\w(:\\|\\\\)\w.*[pst]", 2)

            If IsArray($asPathSearch) Then $sReturn &= $asPathSearch[0] & Chr(28)
        Next
        Return StringSplit(StringTrimRight($sReturn, 1), Chr(28))
    Else
        SetError(1)
        Return 0
    EndIf
EndFunc 
 楼主| 发表于 2011-1-18 17:43:07 | 显示全部楼层
非常感谢你的回复,我先研究下,由衷的感谢!!!
 楼主| 发表于 2011-1-18 18:37:55 | 显示全部楼层
大概都看懂了,查了很多资料,真的太谢谢你了,但是技术实在有限,数组返回后,如何把数组的内容使用变量来显示呢?谢谢帮忙,真的由衷的感谢!
我自己也在继续努力去尝试,但是还是希望您能提供方法来转换,谢谢
发表于 2011-1-18 19:54:41 | 显示全部楼层
回复 6# wsfda


   
#include <Array.au3>
$asPSTPath = _GetPSTPath()

If $asPSTPath[0] > 1 Then MsgBox(0,'',$asPSTPath[1]) ;路径 1
If $asPSTPath[0] > 2 Then MsgBox(0,'',$asPSTPath[2]) ;路径 2
If $asPSTPath[0] >= 3 Then MsgBox(0,'',$asPSTPath[3]) ;路径 3

;If IsArray($asPSTPath) Then _ArrayDisplay($asPSTPath)

Func _GetPSTPath()
        
    Local $sFolderSubString, $sPath, $asPathSearch, $sReturn
        
    Local $oOutlook = ObjCreate("Outlook.Application")
        
    Local $oNS = $oOutlook.GetNamespace("MAPI")

    If IsObj($oNS) Then
                
        For $objFolder In $oNS.Folders
                        
            $sPath = ""
                        
            For $i = 1 To StringLen($objFolder.StoreID) Step 2
                                
                $sFolderSubString = StringMid($objFolder.StoreID, $i, 2)
                                
                If $sFolderSubString <> "00" Then $sPath &= Chr(Dec($sFolderSubString))
                        
                        Next

            $asPathSearch = StringRegExp($sPath, "(?i)\w(:\\|\\\\)\w.*[pst]", 2)

            If IsArray($asPathSearch) Then $sReturn &= $asPathSearch[0] & Chr(28)
                        
        Next
        
        Return StringSplit(StringTrimRight($sReturn, 1), Chr(28))
                
    Else
                
        SetError(1)
                
        Return 0
                
    EndIf
        
EndFunc
 楼主| 发表于 2011-1-19 10:17:38 | 显示全部楼层
非常给力的代码,谢谢A哥,以后好好学习
 楼主| 发表于 2011-1-23 15:42:13 | 显示全部楼层
小弟还有一事请求,获得outlook Express的数据库路径呢,好像和office outlook是不一样的,
帮帮忙,十分感谢各位了
 楼主| 发表于 2011-1-26 11:55:14 | 显示全部楼层
嘿嘿,OE的好像注册表里就有,
发表于 2014-1-4 11:15:40 | 显示全部楼层
我也想了解这个
发表于 2016-5-10 13:00:06 | 显示全部楼层
我测试了一下,非常给你。感谢共享!我在问一个问题,如何知道outlook邮箱的版本和安装路径。
发表于 2016-5-16 13:04:05 | 显示全部楼层
@小A:你写的代码为什么在有的机器是可以获得到PST安装位置路径,有的不行。
发表于 2018-8-15 13:50:34 | 显示全部楼层
本来也想分享的,但是看到前面几位已经分享出来了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-28 06:20 , Processed in 0.085686 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表