Sending emails

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 ...

  1. #1
    Registered User ventolin's Avatar
    Join Date
    Jan 2004
    Posts
    92

    Sending emails

    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,

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,506
    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.

  3. #3
    Registered User ventolin's Avatar
    Join Date
    Jan 2004
    Posts
    92
    Ah sorry, completely slipped my mind when posting,

    WIn XP, VC++

  4. #4
    Registered User
    Join Date
    May 2004
    Posts
    23
    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

  5. #5
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Quote 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"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();
    	
    }

  6. #6
    Registered User ventolin's Avatar
    Join Date
    Jan 2004
    Posts
    92
    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,

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending data - line by line?
    By tuckker in forum C Programming
    Replies: 0
    Last Post: 02-21-2009, 08:31 PM
  2. Sending Email - Using System.Net.Mail
    By b4ip in forum C# Programming
    Replies: 1
    Last Post: 06-01-2007, 12:34 AM
  3. Sending emails through a windows application/openGL
    By two31d in forum C++ Programming
    Replies: 5
    Last Post: 01-28-2006, 01:48 AM
  4. Question - Emails - Viruses
    By MethodMan in forum Tech Board
    Replies: 2
    Last Post: 12-30-2002, 03:57 PM
  5. Sending Email via C++?
    By Monte in forum C++ Programming
    Replies: 0
    Last Post: 07-30-2002, 01:14 PM

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