Click here to Skip to main content
12,446,146 members (77,511 online)
Click here to Skip to main content

Stats

311.4K views
15.5K downloads
179 bookmarked
Posted

SMTP Client

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

int main()
{
	CSmtp mail;

	if(mail.GetLastError() != CSMTP_NO_ERROR)
	{
		printf("%s\n",GetErrorText(mail.GetLastError()));
		return -1;
	}

	mail.SetLogin("***");
	mail.SetPassword("***");
	mail.SetSenderName("JP");
	mail.SetSenderMail("me@mydomain.com");
	mail.SetReplyTo("me@mydomain.com");
	mail.SetSubject("The message");
	mail.AddRecipient("friend@domain.com");
	mail.SetXPriority(XPRIORITY_NORMAL);
	mail.SetXMailer("The Bat! (v3.02) Professional");
	mail.SetMessageBody("This is the message");
	mail.AddAttachment("c:\\test.exe");
	mail.AddAttachment("c:\\test2.jpg");

	if( !mail.ConnectServer("smtp.domain.com",25) ) 
	{
		printf("%s\n",GetErrorText(mail.GetLastError()));
		return -1;
	}
	
	if( mail.Send() )
		printf("The mail was send successfully.\n");
	else
		printf("Unable to send the mail.\n");

	mail.Disconnect();
	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

You may also be interested in...

Pro
Pro
| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160811.3 | Last Updated 16 Jul 2010
Article Copyright 2008 by Jakub Piwowarczyk
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid