VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 给Outlook的所有用户发送信件
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:12866, 日期:2001-04-08
Public Function SendReceiveAll() As Boolean

    Dim oExplorer As Outlook.Explorer
    Dim olNS As Outlook.NameSpace
    Dim olFolder As Outlook.MAPIFolder
    Dim oCtl As Office.CommandBarControl
    Dim oPop As Office.CommandBarPopup
    Dim oNS As Outlook.NameSpace
    Dim oCB As Office.CommandBar
    Dim oOutlookApplication As Outlook.Application

    On Error Resume Next
    
    Set oOutlookApplication = GetObject(, "Outlook.Application")
    If oOutlookApplication Is Nothing Then
        Err.Clear
        On Error GoTo ErrorHandler
        Set oOutlookApplication = _
              CreateObject("Outlook.Application")
        Set olNS = oOutlookApplication.GetNamespace("MAPI")
        Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
        Set oExplorer = olFolder.GetExplorer
    End If
    
    On Error GoTo ErrorHandler
    Set oCB = _
       oOutlookApplication.ActiveExplorer.CommandBars("Standard")
    
    Set oCtl = oCB.Controls("Send/Receive")
    oCtl.Execute
    SendReceiveAll = True
    
ErrorHandler:
    
End Function