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
(Delphi DLL) Attach Email as message/rfc822 sub-part to an EmailDemonstrates how to add attach a message/rfc822 email to another email.
uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, FileAccess, Email, CkByteData; ... procedure TForm1.Button1Click(Sender: TObject); var success: Boolean; emlBytes: HCkByteData; fac: HCkFileAccess; email: HCkEmail; emailToBeAttached: HCkEmail; email2: HCkEmail; emlBytes2: HCkByteData; begin // 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); Memo1.Lines.Add(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); Memo1.Lines.Add('----'); Memo1.Lines.Add(CkEmail__getMime(email2)); CkByteData_Dispose(emlBytes); CkFileAccess_Dispose(fac); CkEmail_Dispose(email); CkEmail_Dispose(emailToBeAttached); CkEmail_Dispose(email2); CkByteData_Dispose(emlBytes2); end; |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.