Sending emails through a windows application/openGL

This is a discussion on Sending emails through a windows application/openGL within the C++ Programming forums, part of the General Programming Boards category; Simple question, with the windows.h/etc, is there a way to send emails through the program?...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    26

    Sending emails through a windows application/openGL

    Simple question, with the windows.h/etc, is there a way to send emails through the program?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,494
    Simple answer - Yes.

  3. #3
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    How do you think people send spam all around the world :P.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  4. #4
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Look at COM interface CDO.IMessage.
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

  5. #5
    Registered User
    Join Date
    Oct 2005
    Posts
    26
    Wow... This looks complicated. Does anyone know of any books documenting this?

  6. #6
    Registered User
    Join Date
    Aug 2002
    Location
    Hermosa Beach, CA
    Posts
    446
    Try this.

    Code:
    # ifndef __MAIL_MESSAGE_H__
    # define __MAIL_MESSAGE_H__
    
    # include "windows.h"
    # include "comdef.h"
    #import <cdosys.dll> raw_interfaces_only, no_namespace
    
    _COM_SMARTPTR_TYPEDEF(Message, __uuidof(IMessage));
    
    class ComBase {
    public:
        ComBase()
        {
    	CoInitialize(NULL);
        }
    
        ~ComBase()
        {
    	CoUninitialize();
        }
    
    };
    
    // TODO:
    // -not sure how to set the SMTP Server
    // -Does this work if Outlook/Outlook Express/Exchange Server is not installed on the machine?
    // -Do Get methods (_bstr_t to TCHAR arrays?)
    // -Add code for attachments
    class MailMessage : public ComBase {
        IMessagePtr pMessage;
    
    public:
        MailMessage()
        {
    	HRESULT hr;
    	hr = pMessage.CreateInstance(__uuidof(Message));
    	if (FAILED(hr)) {
    	    throw _com_error(hr);
    	}
        }
    
        void Send()
        {
    	HRESULT hr;
    	hr = pMessage->Send();
    	if (FAILED(hr)) 
    	    throw _com_error(hr);
        }
    
        void SmtpServer(TCHAR* str)
        {
            // Not sure now to do this...
        }
    
        void Attachment(TCHAR* str)
        {
            // Not sure how to do this part...
        }
    
        void To(TCHAR* str)
        {
    	HRESULT hr;
    	hr = pMessage->put_To(_bstr_t(str));
    	if (FAILED(hr)) {
    	    throw _com_error(hr);
    	}
        }
    
        void From(TCHAR* str)
        {
    	HRESULT hr;
    	hr = pMessage->put_From(_bstr_t(str));
    	if (FAILED(hr)) {
    	    throw _com_error(hr);
    	}
        }
    
        void Sender(TCHAR* str)
        {
    	HRESULT hr;
    	hr = pMessage->put_Sender(_bstr_t(str));
    	if (FAILED(hr)) {
    	    throw _com_error(hr);
    	}
        }
    
        void Subject(TCHAR* str)
        {
    	HRESULT hr;
    	hr = pMessage->put_Subject(_bstr_t(str));
    	if (FAILED(hr)) {
    	    throw _com_error(hr);
    	}
        }
    
        void Body(TCHAR* str)
        {
    	HRESULT hr;
    	hr = pMessage->put_TextBody(_bstr_t(str));
    	if (FAILED(hr)) {
    	    throw _com_error(hr);
    	}
        }
    };
    
    # endif
    The crows maintain that a single crow could destroy the heavens. Doubtless this is so. But it proves nothing against the heavens, for the heavens signify simply: the impossibility of crows.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dialog Box Problems
    By Morgul in forum Windows Programming
    Replies: 21
    Last Post: 05-31-2005, 05:48 PM
  2. dual boot Win XP, win 2000
    By Micko in forum Tech Board
    Replies: 6
    Last Post: 05-30-2005, 02:55 PM
  3. SDL and Windows
    By nickname_changed in forum Windows Programming
    Replies: 14
    Last Post: 10-24-2003, 12:19 AM
  4. IE 6 status bar
    By DavidP in forum Tech Board
    Replies: 15
    Last Post: 10-23-2002, 05:31 PM
  5. Manipulating the Windows Clipboard
    By Johno in forum Windows Programming
    Replies: 2
    Last Post: 10-01-2002, 09:37 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21