Dream Tech Blog

A person with no dream in life can never live a happy life.
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Outlook - GetCurrent Folder / GetSelectedItems / GetInspectors

Posted on 2004-02-18 19:32  Dream  阅读(731)  评论(0编辑  收藏  举报
http://msdn.microsoft.com/library/en-us/vbaol10/html/olobjdistlistitem.asp
http://msdn.microsoft.com/library/en-us/vbaol10/html/olobjInspectors.asp

Sub GetCurrentFolder()
  Dim myolApp As New Outlook.Application
  Dim myOlExp As Outlook.Explorer
  Set myOlExp = myolApp.ActiveExplorer
  MsgBox myOlExp.CurrentFolder.Name
End Sub


Sub GetSelectedItems()
    Dim myolApp As New Outlook.Application
    Dim myOlExp As Outlook.Explorer
    Dim myOlSel As Outlook.Selection
    Dim MsgTxt As String
    Dim x As Integer
    MsgTxt = "You have selected items from: "
    Set myOlExp = myolApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection
    For x = 1 To myOlSel.Count
        MsgTxt = MsgTxt & myOlSel.Item(x).SenderName & ";"
    Next x
    MsgBox MsgTxt
End Sub

Sub GetInspectors()
    Dim myolApp As New Outlook.Application
    If myolApp.Inspectors.Count > 0 Then
        For x = 1 To myolApp.Inspectors.Count
            Set myItem = Inspectors.Item(x)
            MsgBox myItem.Cation
        Next x
    Else
        MsgBox "There are no inspector windows open."
    End If
End Sub