Visual C++ Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Visual C++ Examples

CkString
Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
Encryption
FTP
HTML-to-XML
HTTP
IMAP
MHT / HTML Email
RSA
S/MIME
Socket
Spider
Tar
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
FileAccess
Bzip2
LZW
Icon

 

 

 

 

 

 

 

 

Send Email with a File Attachment

Download Chilkat C/C++ Libraries for VC++ 9.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 8.0 / Win32

Download Chilkat C/C++ 64-bit Libraries for VC++ 8.0 / x64

Download Chilkat Visual Studio 2005 C/C++ Libs for Windows Mobile, Pocket PC, SmartPhone, WinCE

Download Chilkat C/C++ Libraries for VC++ 7.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0 / Win32

Download Chilkat C/C++ Libraries for VC++ 6.0, Win 95/98/NT4 Compatible

C++ code to send an email with a file attachment.

#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 a file attachment.
    CkEmail email;

    email.put_Body("This is the body");

    email.AddTo("Chilkat Support","support@chilkatsoft.com");
    
    email.put_FromAddress("somebody@chilkatsoft.com");

    email.put_Subject("This is a test");

    // Add a file attachment.
    if (!email.AddFileAttachment("dudeCPP.gif",0))
	{
	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.

Mail Component · .NET Mail Component · XML Parser