Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Parse EML and Display Email Subject, Date, From, Recipients, Attachments, and Body
Loads a .eml file into an email object and displays the contents of the mail message. procedure TForm1.Button24Click(Sender: TObject); var email: CHILKATMAILLib2_TLB.IChilkatEmail2; ok: Integer; n: Integer; i: Integer; begin // This example loads an EML (.eml) email file and displays // the contents. EML files contain the MIME message source of an email. // Email clients such as Outlook Express and Mozilla Thunderbird // are capable of saving email in EML format. // A ChilkatMailMan2 ActiveX component was dropped onto the Delphi // form, and this became the Form's member variable "ChilkatMailMan21". // This example uses ChilkatMailMan21 for the purpose of unlocking the component. // The UnlockComponent method only needs to be called once at the beginning // of your Delphi program. ChilkatMailMan21.UnlockComponent('Anything for 30-day trial'); email := ChilkatMailMan21.NewEmail(); email.LoadEml('sample.eml'); Memo1.Lines.Add(email.From); Memo1.Lines.Add(email.Subject); Memo1.Lines.Add(DateTimeToStr(email.LocalDate)); // Show recipients n := email.NumTo; for i := 0 to n-1 do begin Memo1.Lines.Add('To: ' + email.GetTo(i)); end; n := email.NumCC; for i := 0 to n-1 do begin Memo1.Lines.Add('CC: ' + email.GetCC(i)); end; // BCC recipients are not present in the MIME source of an email. // Show attachment filenames and sizes. n := email.NumAttachments; for i := 0 to n-1 do begin Memo1.Lines.Add('Attachment: ' + email.GetAttachmentFilename(i) + ', ' + IntToStr(email.GetAttachmentSize(i)) + ' bytes'); end; // Does this email have a plain-text body? if email.HasPlainTextBody() = 1 then begin Memo1.Lines.Add('------- Plain Text Body -------'); Memo1.Lines.Append(email.GetPlainTextBody()); end; // Show the HTML source of the HTML body... if email.HasHtmlBody() = 1 then begin Memo1.Lines.Add('------- HTML Source of Body -------'); Memo1.Lines.Append(email.GetHtmlBody()); end; end;
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2007 Chilkat Software, Inc. All Rights Reserved.