Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Zip Email Attachments C++ source code to Zip compress email attachments.
#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/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 an email with zipped attachments
CkEmail email;
email.put_Body("This is the email body");
email.AddTo("Chilkat Support","support@chilkatsoft.com");
email.put_FromAddress("somebody@chilkatsoft.com");
email.put_Subject("This is the email subject");
// Add a file attachment.
if (!email.AddFileAttachment("dudeCPP.gif",0))
{
email.SaveLastError("errors.xml");
return;
}
// Add a another file attachment.
if (!email.AddFileAttachment("dude.gif",0))
{
email.SaveLastError("errors.xml");
return;
}
// Zip the attachments.
// The email will now contain one attachment: "a.zip", which contains
// the attachments previously added.
if (!email.ZipAttachments("a.zip"))
{
email.SaveLastError("errors.xml");
return;
}
// Send the 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.