Unicode C++
Unicode C++
Send email using smtp.gmail.com with SSL (port 465).
Send email using smtp.gmail.com with SSL (port 465).Chilkat Unicode C++ Downloads
#include <CkMailManW.h>
#include <CkEmailW.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The mailman object is used for sending and receiving email.
CkMailManW mailman;
// Set the SMTP server.
mailman.put_SmtpHost(L"smtp.gmail.com");
mailman.put_SmtpUsername(L"mySmtpLogin");
mailman.put_SmtpPassword(L"myPassword");
mailman.put_SmtpSsl(true);
mailman.put_SmtpPort(465);
// Create a new email object
CkEmailW email;
email.put_Subject(L"This is a test");
email.put_Body(L"This is a test");
email.put_From(L"Chilkat Support <chilkat.support@gmail.com>");
success = email.AddTo(L"Chilkat Admin",L"admin@chilkatsoft.com");
success = mailman.SendEmail(email);
if (success != true) {
wprintf(L"%s\n",mailman.lastErrorText());
return;
}
success = mailman.CloseSmtpConnection();
if (success != true) {
wprintf(L"Connection to SMTP server not closed cleanly.\n");
}
wprintf(L"Mail Sent!\n");
}