要求发送的邮件内容是HTML格式而不是文本格式的,请问用什么控件可以实现!
解决方案 »
- Delphi / C++Builder Beta 7.5 Build 16.0.4217.41600
- 工资自定义公式模块的实现
- 请问静态一维数组的上标最大值可设多少?
- 求助:两个DBGRID 一个DBLookupComBox
- 【RichEdit问题】如何在程序里向RichEdit输入文字以后始终显示最后面的?
- 用IDFTP做FTP客户端的连接问题,代码如下,一运行就死掉,为什么?
- 求教个SQL语句
- 我回来了,又从cb转回delphi了,,幸福呀!!!!散分!!!!!!
- 在quickreport中,该如何解决如下问题?
- ADOQuery中的哪个属性表示相连数据表中的记录总数?
- Query查询出的结果保存入表单2中
- ABC 问题。
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MWesternLib_TLB;type
TForm1 = class(TForm)
Label1: TLabel;
From: TEdit;
Label4: TLabel;
Label5: TLabel;
ToName: TEdit;
Label6: TLabel;
ToAddress: TEdit;
SendMail: TButton;
Label7: TLabel;
Body: TMemo;
SendWebPage: TButton;
SendHtmlComplete: TButton;
Label8: TLabel;
WebUrl: TEdit;
Label9: TLabel;
HtmlFile: TEdit;
Label10: TLabel;
Subject: TEdit;
Status: TLabel;
procedure SendMailClick(Sender: TObject);
procedure SendWebPageClick(Sender: TObject);
procedure SendHtmlCompleteClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}// Delphi example to send a simple plain-text Western email.
procedure TForm1.SendMailClick(Sender: TObject);
var
mail: IMWestern;
begin
Status.Caption := 'Sending...';
Status.Refresh(); mail := CoMWestern.Create(); // Unlock the component and point to the SMTP server.
mail.UnlockComponent('unlockCode');
mail.SmtpHost := 'smtp.earthlink.net'; // Set email header fields.
mail.AddHeaderField('From',From.Text);
mail.AddRecipient('To',ToName.Text,ToAddress.Text);
mail.AddHeaderField('Subject',Subject.Text); // Set the plain-text email body.
mail.SetPlainTextBody(Body.Text); // Save the email to an Outlook Express EML file (MIME format)
mail.WriteFile('mail.eml',mail.ExportToMime()); // Convert the entire email to iso-8859-1 regardless of the character
// encodings present.
mail.ConvertToIso8859_1(); // Send the mail.
if (mail.SendMail() = 0) then
Status.Caption := 'Send Failed'
else
Status.Caption := 'Mail Sent';end;// Delphi example to convert a Western Web page to email and send.
procedure TForm1.SendWebPageClick(Sender: TObject);
var
mail: IMWestern;
begin
Status.Caption := 'Sending...';
Status.Refresh(); mail := CoMWestern.Create(); mail.UnlockComponent('unlockCode');
mail.SmtpHost := 'smtp.earthlink.net'; // Set email header fields.
mail.AddHeaderField('From',From.Text);
mail.AddRecipient('To',ToName.Text,ToAddress.Text); // Download the Web page into the mail object. The email subject
// is initialized to the title of the Web page.
mail.LoadHtmlComplete(WebUrl.Text);
mail.AddHeaderField('Subject',Subject.Text); // Save the email to an Outlook Express EML file (MIME format)
mail.WriteFile('mail2.eml',mail.ExportToMime()); // Convert the entire email to iso-8859-1, regardless of the current
// encodings. The entire HTML is also converted, and the HTML meta tag
// specifing the charset is updated or added.
mail.ConvertToIso8859_1(); // Send the mail.
if (mail.SendMail() = 0) then
Status.Caption := 'Send Failed'
else
Status.Caption := 'Mail Sent';end;// Delphi example to convert a Western HTML file to email and send.
procedure TForm1.SendHtmlCompleteClick(Sender: TObject);
var
mail: IMWestern;
begin
Status.Caption := 'Sending...';
Status.Refresh(); // Create an instance of the Western mail object.
mail := CoMWestern.Create(); // Unlock the component and set the SMTP server.
mail.UnlockComponent('unlockCode');
mail.SmtpHost := 'smtp.earthlink.net'; // Set email header fields.
mail.AddHeaderField('From',From.Text);
mail.AddRecipient('To',ToName.Text,ToAddress.Text); // Load the HTML file. This also loads all images and style sheets
// and embeds them into the email.
mail.LoadHtmlComplete(HtmlFile.Text);
mail.AddHeaderField('Subject',Subject.Text); // Save the email to an Outlook Express formatted file.
mail.WriteFile('mail2.eml',mail.ExportToMime()); // Convert the entire email to ISO-8859-1, regardless of existing
// encodings.
mail.ConvertToIso8859_1(); // Send the mail.
if (mail.SendMail() = 0) then
Status.Caption := 'Send Failed'
else
Status.Caption := 'Mail Sent';end;end.