Hi,
just a quick question, does anyone know of a library/wrapper class which i can use send simple e-mails within a c++ application? eg using SMTP/POP/MAPI etc
Thanks in advance,
This is a discussion on Sending emails within the C++ Programming forums, part of the General Programming Boards category; Hi, just a quick question, does anyone know of a library/wrapper class which i can use send simple e-mails within ...
Hi,
just a quick question, does anyone know of a library/wrapper class which i can use send simple e-mails within a c++ application? eg using SMTP/POP/MAPI etc
Thanks in advance,
Which OS/Compiler?
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I support http://www.ukip.org/ as the first necessary step to a free Europe.
Ah sorry, completely slipped my mind when posting,
WIn XP, VC++
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!Originally Posted by ShortCoder
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"whatever@whatever.co.uk"); lpIMsg->put_From(L"Bill.Gates@microsoft.com"); 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(); }
Ok thanks for the information, ill check out the website and have a look at some of the stuff their.
(by the way i do have linux (red hat 9) its just currently i dont have internet working with it at the moment so i was seeing if it was possible under windows/vc++)
thanks for the code example - ill check this out
Cheers,