Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Send Signed + Encrypted Email Sample C++ program to send signed and encrypted email. #define _CRTDBG_MAP_ALLOC
#include <windows.h>
#include <stdio.h>
#include <crtdbg.h>
#include "C:/ck2000/components/ChilkatLib/Package/Include/CkSettings.h"
#include "C:/ck2000/components/ChilkatLib/Package/Include/CkCert.h"
#include "C:/ck2000/components/ChilkatLib/Package/Include/CkEmail.h"
#include "C:/ck2000/components/ChilkatLib/Package/Include/CkEmailBundle.h"
#include "C:/ck2000/components/ChilkatLib/Package/Include/CkMailMan.h"
#include "C:/ck2000/components/ChilkatLib/Package/Include/CkString.h"
#include "C:/ck2000/components/ChilkatLib/Package/Include/CkByteData.h"
void EmailExample(void)
{
CkMailMan mailman;
// Any string passed to UnlockComponent begins the 30-day trial.
bool unlocked = mailman.UnlockComponent("30-day trial");
if (!unlocked)
{
printf("Failed to unlock component\n");
return;
}
mailman.put_SmtpHost("mail.earthlink.net");
// Send a signed + encrypted email.
CkEmail email;
email.put_Body("This is the email body");
email.put_Subject("This is the email subject");
// Load certificates for signing and encrypting.
// The signing certificate must match the sender's email address.
// The encrypting certificate must match the recipient's email address.
CkCert cert1;
cert1.LoadFromFile("signingCert.cer");
CkCert cert2;
cert2.LoadFromFile("encryptCert.cer");
// The To address must match the email address in the encrypting certificate:
email.AddTo("Chilkat Support","support@chilkatsoft.com");
// The From address must match the email address in the signing certificate.
email.put_FromAddress("matt@chilkatsoft.com");
// Use the certificates ...
email.put_SendSigned(true);
email.SetSigningCert(&cert1);
email.put_SendEncrypted(true);
email.SetEncryptCert(&cert2);
// Send the signed + encrypted email
if (!mailman.SendEmail(&email))
{
mailman.SaveLastError("errors.xml");
}
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
freopen("stdout.txt","w",stdout);
EmailExample();
CkSettings::cleanupMemory();
_CrtDumpMemoryLeaks();
return 0;
}
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.