Share via


GetMessages Method

GetMessages Method

The GetMessages method returns a collection containing the messages in the specified directory.

Syntax

Function GetMessages([ByVal DirName as String]) as IMessagesHRESULT 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.

Remarks

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

Example

' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
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