Simple Email Client v1.3


Author: Emmanuel KARTMANN.

Creation Date: November 28th, 1998
Last Modification Date: February 8th, 2000


Using the SimpleEmailClient in dialog-based program

OVERVIEW

This ATL COM component provides very simple Internet email functionality (SMTP).

FEATURES

USAGE

To use this component:

SAMPLE CODE (VC++)


    // Import smart pointer definition
    #import "SimpleEmailClient.dll" no_namespace

    // Create smart pointer object
    ISimpleEmailClientXPtr pSimpleEmailClientX;

    // =======================================================================
	// Initialize COM (This should be called at thread startup)
    // =======================================================================
    HRESULT hResult = CoInitialize(NULL); 
    if (FAILED(hResult)) {
        ErrorDialogBox("Cannot initialize COM: \n", hResult);
        return; // Failed
    }
	
    // =======================================================================
	// Create instance of the component to test
    // =======================================================================
    try 
    {
        HRESULT hResult = S_OK;
        // Create object
        hResult = pSimpleEmailClientX.CreateInstance("Emmanuel.SimpleEmailClientX.1");
        if (FAILED(hResult)) {
            ErrorDialogBox("Cannot create component Emmanuel.SimpleEmailClientX.1: \n", hResult);
        }
    }
    catch (_com_error &e)
    {
        ErrorDialogBox("Cannot create component Emmanuel.SimpleEmailClientX.1: \n", e);
    }

    // =======================================================================
    // Call method of component
    // =======================================================================
    try 
    {
        HRESULT hResult = S_OK;
        hResult = pSimpleEmailClientX->SendEmail(_bstr_t(m_szFrom), _bstr_t(m_szTo), _bstr_t(m_szSubject), _bstr_t(m_szBody), _bstr_t(m_szServerName));
        if (FAILED(hResult)) {
            ErrorDialogBox("Failure while executing method SendMail: \n", hResult);
        }
    }
    catch (_com_error &e)
    {
        ErrorDialogBox("Failure while executing method SendMail: \n", e);
    }

    // =======================================================================
    // UnInitialize COM (This should be called at thread exit)
    // =======================================================================
    CoUninitialize(); 

Please refer to the demo project for a full example. Note that you should extract the demo project underneath the component project:

SAMPLE CODE (VBScript)


	Dim oSMTP

	Set oSMTP = CreateObject("Emmanuel.SimpleEmailClientX.1")

	oSMTP.SendEmail "me@mydomain.com", "you@yourdomain.com", "My Subject", "My Text...", "myserver.domain.com"

Please refer to the test HTML file "TestSimpleEmailClient.htm" for a full VBSsript example (see GUI below)

Using the SimpleEmailClient in Internet Explorer

IMPLEMENTATION

This component relies on two MFC-related C++ class:

You can integrate these classes in your application if you don't want to use the component.

If the COMponent "Emmanuel.SimpleDNSClient" is installed on your machine, it will be used to find the name of you SMTP server(s) as registered in the DNS. You will not need to provide a SMTP name as the 5th parameter of method SendEmail (just put an empty string). Please refer to the SimpleDNSClient documentation (www.kartmann.com/emmanuel) for details.

TO DO LIST