send email using c++

How to send email using C++ ?
need an example
i'm using codeblock
Can't do it with pure C++, you'll need an external library. You can ask this question to Google and find plenty of libraries/code
Use https://curl.haxx.se/libcurl/ to do all the low level stuff.
Examples using IMAP, POP and SMTP.

{$reference '%GAC%\System.dll'}
Easily translate from Pascal to C ++

type
SMTPClient = class
private
_smtpproc : System.Net.Mail.SmtpClient; //.NET
_from : string;
_recipients : string;
_subject : string;
_txtmsg : string;
_sended : boolean;
procedure _SendCompleted(sender: System.Object; e: System.ComponentModel.AsyncCompletedEventArgs);
begin
//if _smtpproc.SendCompleted<>nil then _smtpproc.SendCompleted(sender, e);
end;
procedure Init(from: string; recipients: string; subject: string);
begin
_from := from; // отправитель / sender
_recipients := recipients; // получатель / recipient
_subject := subject; // тема сообщения / message subject
// Событие "По завершению отправки" определено !
_smtpproc.SendCompleted += _SendOK; //_SendCompleted;
end;
public
//event _SendCompleted: System.Net.Mail.SendCompletedEventHandler;
/// отправитель получатель тема сообщения
/// sender recipient message subject
constructor Create (host: string; port: integer; from: string; recipients: string; subject: string);
begin
_smtpproc := new System.Net.Mail.SmtpClient (host,port);
Init (from, recipients, subject);
end;
procedure Destroy;
begin
_smtpproc.Dispose;
end;
procedure SendProcess;
begin
try
_info ( 'Attempt send e-mail' );
_smtpproc.Send(_from,_recipients,_subject,_txtmsg);
_info ( 'Send e-mail OK' );
except
_info ( 'Send e-mail ERROR' );
end;
end;
procedure SendAction(o: Object);
begin
SendProcess;
end;
procedure SendMessage(message: string);
begin
_txtmsg := message;
if ThreadPool.QueueUserWorkItem(SendAction)
then _info ( 'E-mail '''+_txtmsg+''' in queue.' )
else _info ( 'E-mail '''+_txtmsg+''' do not send,' );
//SendProcess;
end;
end;
Registered users can post here. Sign in or register to post.