delphi 发送html邮件,如何使用IdSMTP(Delphi)发送带有html-contetent的电子邮件?

不得不最近使用Indy IdSmtp组件,遗憾的是这个问题没有很好的答案.我重新编写了我们的帮助函数,使用Indy(HTML和纯文本)发送电子邮件

样本用法

SendHtmlEmailIndy(

'smtp.stackoverflow.com',//the SMTP server address

'Spammy McSpamerson','spams@example.com',//From name,from e-mail address

'joe@foo.net,jane@bar.net',//To addresses - comma separated

'john@doe.net',//CC addresses - comma separated

'',//BCC addresses - comma separated

'Here is your sample spam e-mail',//Subject

'gt;

棘手的部分是Indy使发送HTML电子邮件变得困难.他们最终提供了一个TIdMessageBuilderHtml类来处理大部分繁琐的工作;但它远没有像SmtpClient类那样令人愉快.最后,你会依赖三个单位.

procedure SendEmailIndy(

const SMTPServer: string;

const FromName,FromAddress: string;

const ToAddresses: string; //comma "," separated list of e-mail addresses

const CCAddresses: string; //comma "," separated list of e-mail addresses

const BCCAddresses: string; //comma "," separated list of e-mail addresses

const Subject: string;

const EmailBody: string;

const IsBodyHtml: Boolean; //verses Plain Text

const Attachments: TStrings);

var

smtp: TIdSMTP; // IdSmtp.pas

msg: TidMessage; // IdMessage.pas

builder: TIdCustomMessageBuilder; //IdMessageBuilder.pas

s: string;

emailAddress: string;

begin

{

Sample usage:

SendEmailIndy(

'smtp.stackoverflow.com',//the SMTP server address

'Spammy McSpamerson',from e-mail address

'joe@foo.net,//To addresses - comma separated

'john@doe.net',//CC addresses - comma separated

'',//BCC addresses - comma separated

'Here is your sample spam e-mail',//Subject

'gt;

Note: Any code released into public domain. No attribution required.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值