Create the ATL Project and Set Up SMTP Event Headers

Create the ATL Project and Set Up SMTP Event Headers

  1. Start Microsoft Visual C++ 6.0 and create a new project using the ATL COM AppWizard. Call the new project "ShieldsUp." This sink will be a dynamic link library (DLL) in-process COM server. Select this option. We do not need MFC or MTS support, nor do we care about merging of proxy/stub code. Leave these options unchecked and select Finish.

  2. In the ClassView, right-click on the ShieldsUp classes and select New ATL Object. Select the Objects category, and select Simple Object from the list of objects. Select Next.

    1. In the Names tab, enter a name for the class. For this example, the name Sink will be fine. Leave the defaults for all the rest of the boxes.
    2. In the Attributes tab, under Threading Model, select Free, and leave the rest of the options. We will support a dual interface (IDispatch along with the v-table) for the ISink interface, and aggregation is not a concern. We don't need the free-threaded marshaller, nor to support Connection Points. Supporting ISupportErrorInfo could be useful for our interface ISink, but we leave this unchecked for this example.
  3. First we add the interface IID and other various GUID definitions to the project. You can simply include these in a compiled file, or add them to the project as source files. In this project we just add #include statements to the file ShieldsUp.cpp:

    #include "stdafx.h"
    #include "resource.h"
    #include <initguid.h>
    #include "ShieldsUp.h"
    
    #include "ShieldsUp_i.c"
    #include "Sink.h"
    
    #include "seo_i.c"#include "mailmsg_i.c"
    

    Note   The seo_i.c, seo.h, mailmsg_i.c, mailmsg.h, and smtpevent.h files are generated from the Seo.Idl, MailMsg.Idl, and SmtpEvent.Idl files, respectively. Seo.Idl, MailMsg.Idl, and SmtpEvent.Idl are included in the Platform SDK download. Prior to creating this project, generate the *.c and *.h files using the MIDL Compiler. For more information about using the MIDL Compiler, see the "Microsoft Interface Definition Language" section of the Platform SDK.

  4. In the header file Sink.h, we add the header files containing the type information for SEO, the MailMsg COM class and associated interfaces, and the protocol event interface.
    Sink.h

    // Sink.h : Declaration of the CSink
    
    #ifndef __SINK_H_
    #define __SINK_H_
    
    #include "resource.h"       // main symbols
    #include "mailmsg.h"#include "smtpevent.h"#include "seo.h"