Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create Multipart/Alternative MIMECreate a simple multipart/alternative MIME message. uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, CHILKATMIMELib_TLB, OleCtrls; ... procedure TForm1.Button1Click(Sender: TObject); var mime: CHILKATMIMELib_TLB.IChilkatMime; success: Integer; ptMime: CHILKATMIMELib_TLB.IChilkatMime; htMime: CHILKATMIMELib_TLB.IChilkatMime; begin mime := CoChilkatMime.Create(); success := mime.UnlockComponent('Anything for 30-day trial'); if (success = 0) then begin ShowMessage('Failed to unlock'); Exit; end; // Make this a multipart/alternative MIME message: mime.NewMultipartAlternative(); // Create a plain-text part and add it to the multipart/alternative MIME. ptMime := CoChilkatMime.Create(); ptMime.SetBodyFromPlainText('This is the plain-text body'); mime.AppendPart(ptMime); // Now do the same for HTML: htMime := CoChilkatMime.Create(); htMime.SetBodyFromHtml('<html><body>This is the HTML body</body></html>'); mime.AppendPart(htMime); // Show the full multipart/alternative MIME text which includes both parts: Memo1.Lines.Add(mime.GetMime()); // Need to change the boundary string? mime.Boundary := '__NewBoundaryString__123'; // Need to change the charset? ptMime := mime.GetPart(0); ptMime.Charset := 'utf-8'; htMime := mime.GetPart(1); htMime.Charset := 'utf-8'; // Need to change the encoding? htMime.Encoding := 'base64'; // Now show the MIME again: Memo1.Lines.Add('---- After Changes ----'); Memo1.Lines.Add(mime.GetMime()); end; |
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.