Simple question, with the windows.h/etc, is there a way to send emails through the program?
Simple question, with the windows.h/etc, is there a way to send emails through the program?
Simple answer - Yes.
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 *)
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.
Wow... This looks complicated. Does anyone know of any books documenting this?
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.