Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Send Multipart/Alternative Email
Delphi example code to send an email containing both HTML and plain-text alternative bodies. // Delphi example to send a multipart/alternative email. // A multipart/alternative email is an email that has both // a plain-text body and an HTML body. The email client displays // one or the other, depending on the capability of the client. procedure TForm1.Button13Click(Sender: TObject); var email: IChilkatEmail2; ok: Integer; contentId: WideString; begin // A ChilkatMailMan2 ActiveX component was dropped onto the Delphi // form, and this became the Form's member variable "ChilkatMailMan21". ChilkatMailMan21.UnlockComponent('Anything for 30-day trial'); ChilkatMailMan21.SmtpHost := 'smtp.comcast.net'; // If our SMTP server requires authentication, set the username/password. //ChilkatMailMan21.SmtpUsername := 'myUsername'; //ChilkatMailMan21.SmtpPassword := 'myPassword'; email := ChilkatMailMan21.NewEmail(); email.Subject := 'Email sent from a Delphi program!'; email.From := 'Chilkat Support <support@chilkatsoft.com>'; email.AddTo('Chilkat Admin','admin@chilkatsoft.com'); // Add a GIF image as a related-item to the email. This GIF image will // be displayed within the HTML email body. contentId := email.AddRelatedFile('dude.gif'); // Add the HTML alternative body. email.AddHtmlAlternativeBody('<html><body>This is an HTML email...<p><img src="cid:' + contentId + '" /></body></html>'); // Add the plain-text alternative body. email.AddPlainTextAlternativeBody('This is the plain-text alternative body'); //Save the email as an EML file so we can review the MIME if desired... email.SaveEml('e.eml'); // Connect to the SMTP server and send the email. ok := ChilkatMailMan21.SendEmail(email); if (ok = 0) then ChilkatMailMan21.SaveLastError('errorLog.xml'); end;
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.