다음을 통해 공유


GetMessages Method

Topic Last Modified: 2006-06-13

Returns a collection containing the messages in the specified directory.

Applies To

IDropDirectory Interface

Type Library

Microsoft CDO for Exchange 2000 Library

DLL Implemented In

CDOEX.DLL

Syntax

Function GetMessages(    ByVal [DirName As String]) As IMessages
HRESULT GetMessages
(
        BSTR DirName,
        IMessages** pVal
);

Parameters

  • DirName
    The path to a directory that contains the messages. This parameter is optional, and if the empty string "" is specified, the currently defined SMTP drop directory is assumed.

Return Value

Returns S_OK if successful, or an error value otherwise.

Remarks

The collection returned by GetMessages contains Message objects derived from the files present in the directory at the time the method was invoked. The collection is not automatically updated when new messages arrive in the directory. To refresh the collection, call GetMessages again to retrieve a new collection.

Examples


Dim iDropDir as New CDO.DropDirectory
Dim iMsgs as CDO.IMessages
Set iMsgs = iDropDir.GetMessages("c:\Inetput\mailroot\Drop")
' you now have the collection of messages
' in the SMTP drop directory
...
Set iMsgs = iDropDir.GetMessages("c:\mymessages")
' you now have the collection of messages
' located in the directory c:\mymessages



#import "c:\program files\common files\system\ado\msado15.dll" no_namespace raw_interfaces_only
#import <cdosys.dll> no_namespace raw_interfaces_only
main() {
  CoInitialize(NULL);

  IDropDirectory* pDropDir = NULL;
  IMessages*      pMsgs    = NULL;
  CoCreateInstance(
    __uuidof(DropDirectory),
    NULL,
    CLSCTX_INPROC_SERVER,
    __uuidof(IDropDirectory),
    (void**)pDropDir);
    // get collection from SMTP drop directory
    pDropDir->GetMessages(L"c:\\Inetput\\mailroot\\Drop",&pMsgs);
   // ...
    pMsgs->Release();
   // get collection from specific directory
    pDropDir->GetMessages(L"c:\\mymessages",&pMsgs);
   //  ...
   pMsgs->Release();
   pDropDir->Release();
  CoUninitialize();
  return 1;
}


Dim iDropDir
Set iDropDir = CreateObject("CDO.Configuration")
Dim iMsgs
Set iMsgs = iDropDir.GetMessages("c:\Inetpub\mailroot\Drop")
' you now have the collection of messages
' in the SMTP drop directory
...
Set iMsgs = iDropDir.GetMessages("c:\mymessages")
' you now have the collection of messages
' located in the directory c:\mymessages