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
(Unicode 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_CkFileAccessW.h> #include <C_CkEmailW.h> void ChilkatSample(void) { BOOL success; HCkByteData emlBytes; HCkFileAccessW fac; HCkEmailW email; HCkEmailW emailToBeAttached; HCkEmailW email2; HCkByteData emlBytes2; // In this example, we'll attach an email loaded from a .eml file to a new email. emlBytes = CkByteData_Create(); fac = CkFileAccessW_Create(); success = CkFileAccessW_ReadEntireFile(fac,L"qa_data/eml/simple.eml",emlBytes); email = CkEmailW_Create(); CkEmailW_putSubject(email,L"This is a test email with an attached email."); CkEmailW_putBody(email,L"Test with attached email."); CkEmailW_AddTo(email,L"Joe",L"joe@example.com"); CkEmailW_putFrom(email,L"mary@example.com"); success = CkEmailW_AttachMessage(email,emlBytes); wprintf(L"%s\n",CkEmailW_getMime(email)); // ---------------------------------------------------------------------- // Alternatively, we could do this: emailToBeAttached = CkEmailW_Create(); success = CkEmailW_LoadEml(emailToBeAttached,L"qa_data/eml/simple.eml"); email2 = CkEmailW_Create(); CkEmailW_putSubject(email2,L"This is a test email with an attached email."); CkEmailW_putBody(email2,L"Test with attached email."); CkEmailW_AddTo(email2,L"Joe",L"joe@example.com"); CkEmailW_putFrom(email2,L"mary@example.com"); emlBytes2 = CkByteData_Create(); success = CkEmailW_GetMimeBinary(emailToBeAttached,emlBytes2); success = CkEmailW_AttachMessage(email2,emlBytes2); wprintf(L"----\n"); wprintf(L"%s\n",CkEmailW_getMime(email2)); CkByteData_Dispose(emlBytes); CkFileAccessW_Dispose(fac); CkEmailW_Dispose(email); CkEmailW_Dispose(emailToBeAttached); CkEmailW_Dispose(email2); CkByteData_Dispose(emlBytes2); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.