Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

SMTP Client

, 16 Jul 2010
The CSmtp class allows to send emails with attachments. It only provides the AUTH LOGIN authentication.
CSmtp.zip
CSmtp
CSmtp.dsp
CSmtp.dsw
CSmtp_v1_1.zip
CSmtp.dsp
CSmtp.dsw
CSmtp_v1_2.zip
CSmtp.dsp
CSmtp.dsw
CSmtp_v1_3.zip
CSmtp_v1_3
CSmtp.dsp
CSmtp.dsw
CSmtp_v1_4.zip
CSmtp_v1_4
CSmtp.dsp
CSmtp.dsw
CSmtp.ncb
CSmtp.opt
CSmtp.plg
CSmtp_v1_5.zip
CSmtp_v1_5
CSmtp.dsp
CSmtp.dsw
CSmtp.ncb
CSmtp.opt
CSmtp.plg
CSmtp_v1_6.zip
CSmtp_v1_6
CSmtp.dsp
CSmtp.dsw
CSmtp.opt
CSmtp.plg
CSmtp_v1_7.zip
CSmtp_v1_7
CSmtp.dsp
CSmtp.dsw
CSmtp.ncb
CSmtp.opt
CSmtp_v1_8a.zip
CSmtp_v1_8a
CSmtp.dsp
CSmtp.dsw
CSmtp_v1_8b.zip
CSmtp_v1_8b
makefile
#include "CSmtp.h"
#include <iostream>

int main()
{
	bool bError = false;

	try
	{
		CSmtp mail;

		mail.SetSMTPServer("smtp.domain.com",25);
		mail.SetLogin("***");
		mail.SetPassword("***");
  		mail.SetSenderName("User");
  		mail.SetSenderMail("user@domain.com");
  		mail.SetReplyTo("user@domain.com");
  		mail.SetSubject("The message");
  		mail.AddRecipient("friend@domain2.com");
  		mail.SetXPriority(XPRIORITY_NORMAL);
  		mail.SetXMailer("The Bat! (v3.02) Professional");
  		mail.AddMsgLine("Hello,");
		mail.AddMsgLine("");
		mail.AddMsgLine("...");
		mail.AddMsgLine("How are you today?");
		mail.AddMsgLine("");
		mail.AddMsgLine("Regards");
		mail.ModMsgLine(5,"regards");
		mail.DelMsgLine(2);
		mail.AddMsgLine("User");
		
  		//mail.AddAttachment("../test1.jpg");
  		//mail.AddAttachment("c:\\test2.exe");
		//mail.AddAttachment("c:\\test3.txt");
		mail.Send();
	}
	catch(ECSmtp e)
	{
		std::cout << "Error: " << e.GetErrorText().c_str() << ".\n";
		bError = true;
	}
	if(!bError)
		std::cout << "Mail was send successfully.\n";
	return 0;
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jakub Piwowarczyk
Engineer Technical University of Lodz
Poland Poland
No Biography provided

| Advertise | Privacy | Mobile
Web01 | 2.8.140921.1 | Last Updated 16 Jul 2010
Article Copyright 2008 by Jakub Piwowarczyk
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid