Originally Posted by
ShortCoder
For stuff like this, you are MUCH more likely to find something useable as a library if you are under Linux. You can always try searching
http://www.freshmeat.net and see what results you get. I found a lot of those for Linux but none for Windows---you generally get better luck with pre-built programmer libraries if you use Linux
Yeah..because people with windows dont have the option of email!
Windows has a few decent email libraries depending on the version and what apps are installed.
For sending email on a basic WinXP setup and as you have VC++, you should have a look at the CDO for Windows 2000 library. It's pretty lightweight and simple. It's based on ActiveX so once you know the library it can be used in C++, Visual Basic or even JScript!
Code:
#import "C:\Program Files\Common Files\System\ado\msado26.tlb" no_namespace raw_interfaces_only
#import "C:\winnt\system32\cdosys.dll" no_namespace raw_interfaces_only
#include <windows.h>
#include <comdef.h>
#include <iostream>
int main()
{
CoInitialize(0);
try
{
//Create a configuration object
IConfigurationPtr lpIConf;
lpIConf.CreateInstance(L"CDO.Configuration");
//Set and update fields
FieldsPtr lpIFields = 0;
lpIConf->get_Fields(&lpIFields);
FieldPtr lpIField = 0;
lpIFields->get_Item(_variant_t(cdoSendUsingMethod),&lpIField);
lpIField->put_Value(_variant_t(cdoSendUsingPort));
lpIFields->get_Item(_variant_t(cdoSMTPServer),&lpIField);
lpIField->put_Value(_variant_t(L"smtp.whatever.com"));
lpIFields->Update();
//Create a message Object
IMessagePtr lpIMsg;
lpIMsg.CreateInstance(L"CDO.Message");
lpIMsg->put_Configuration(lpIConf);
lpIMsg->put_To(L"[email protected]");
lpIMsg->put_From(L"[email protected]");
lpIMsg->put_Subject(L"Whatever");
lpIMsg->put_TextBody(L"Rhubarb...Rhubarb...Rhubarb!");
lpIMsg->Send();
}
catch(_com_error& e)
{
std::cout << e.ErrorMessage() << std::endl;
}
CoUninitialize();
}