Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(C) Attach Email as message/rfc822 sub-part to an EmailDemonstrates how to add attach a message/rfc822 email to another email.
#include <C_CkByteData.h> #include <C_CkFileAccess.h> #include <C_CkEmail.h> void ChilkatSample(void) { BOOL success; HCkByteData emlBytes; HCkFileAccess fac; HCkEmail email; HCkEmail emailToBeAttached; HCkEmail email2; HCkByteData emlBytes2; // In this example, we'll attach an email loaded from a .eml file to a new email. emlBytes = CkByteData_Create(); fac = CkFileAccess_Create(); success = CkFileAccess_ReadEntireFile(fac,"qa_data/eml/simple.eml",emlBytes); email = CkEmail_Create(); CkEmail_putSubject(email,"This is a test email with an attached email."); CkEmail_putBody(email,"Test with attached email."); CkEmail_AddTo(email,"Joe","joe@example.com"); CkEmail_putFrom(email,"mary@example.com"); success = CkEmail_AttachMessage(email,emlBytes); printf("%s\n",CkEmail_getMime(email)); // ---------------------------------------------------------------------- // Alternatively, we could do this: emailToBeAttached = CkEmail_Create(); success = CkEmail_LoadEml(emailToBeAttached,"qa_data/eml/simple.eml"); email2 = CkEmail_Create(); CkEmail_putSubject(email2,"This is a test email with an attached email."); CkEmail_putBody(email2,"Test with attached email."); CkEmail_AddTo(email2,"Joe","joe@example.com"); CkEmail_putFrom(email2,"mary@example.com"); emlBytes2 = CkByteData_Create(); success = CkEmail_GetMimeBinary(emailToBeAttached,emlBytes2); success = CkEmail_AttachMessage(email2,emlBytes2); printf("----\n"); printf("%s\n",CkEmail_getMime(email2)); CkByteData_Dispose(emlBytes); CkFileAccess_Dispose(fac); CkEmail_Dispose(email); CkEmail_Dispose(emailToBeAttached); CkEmail_Dispose(email2); CkByteData_Dispose(emlBytes2); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.