以下Outlook VBA 的作用在於將特定目錄下的連絡人資料夾,顯示為電子郵件通訊錄
Sub ContactsFolder()
Dim myNameSpce As Outlook.NameSpace
Dim mySourFolder, myDestFolder As Outlook.MAPIFolder
Dim thisFolder As Outlook.MAPIFolder
Dim uName As String
Set myNameSpace = Application.GetNamespace("MAPI")
myNameSpace.AddStore "D:\Mail\通訊錄.pst" '開啟預設通訊錄檔案
Set mySourFolder = myNameSpace.Folders("通訊錄").Folders("G-SPEC 連絡人") '來源資料檔"收件匣"物件
For i = 1 To mySourFolder.Folders.Count
Set thisFolder = mySourFolder.Folders(i)
If thisFolder.ShowAsOutlookAB = False Then '判斷是否未選擇顯示該連絡人目錄
thisFolder.ShowAsOutlookAB = True '將此資料夾顯示為電子郵件通訊錄
MsgBox ("顯示通訊錄 " & thisFolder.Name)
End If
Next i
Set myNameSpace = Nothing
End Sub
沒有留言:
張貼留言