Receiving Email
The only way to read email with CDO for Windows 2000 is to use it in conjunction with Microsoft’s SMTP service. The SMTP service receives all email messages targeted to a specific domain and writes them to a predetermined directory, known as the drop directory. After emails have been placed in the drop directory, they are available to your Visual Basic program via the DropDirectory class in CDO for Windows 2000.
The DropDirectory class represents the SMTP service’s drop directory. The class has no properties and only a single method, the GetMessages method. The syntax of the GetMessages method is:
Function GetMessages([ByVal DirName
As String]) As IMessages
The DirName
parameter specifies the full
path of the drop directory. If the parameter is omitted or passed as
an empty string, CDO for Windows 2000 looks to IIS on the local
machine, if present, to discover where the drop directory is. Neither
the drop directory nor the SMTP service need be on the local machine.
The only requirement is that the local machine has access to the drop
directory.
The value returned by the
GetMessages method is an IMessages
collection of
Message objects. Example 12-3 shows a subroutine that
iterates through the messages found in the specified drop directory,
printing each message’s subject text to Visual Basic’s
Immediate window.
Example 12-3. Iterating Through the Messages Found in the Drop Directory
Private Sub ReceiveEmail( ) Const cstrDropDirectory As String = _ "\\MyServer\MyShare\Inetpub\Mailroot\Drop\" ...
Get CDO & MAPI Programming with Visual Basic: now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.