如何从 Indy TIdMessage 对象中提取所有电子邮件地址?
How to extract all email address from an Indy TIdMessage object?
如何使用 Indy 提取 TIdMessage
的 To
、Cc
和 Bcc
字段中存在的所有电子邮件地址?由于这些字段可以包含多个地址,我必须解析它们,但我没有找到任何现成的函数(也许我错过了?)。
你显然没有阅读
TIdMessage.Recipients
Identifies the recipients of a message.
property Recipients: TIdEmailAddressList;
Description
Recipients is a TIdEMailAddressList
property used to store TIdEmailAddressItem
values that identify the recipients of the message. Use CCList
for recipients to receive a Carbon Copy of the message. Use BCCList
for recipients to receive a Blind Carbon Copy of the message.
所有这些属性都为您提供了一个 TIdEmailAddressList
,您可以从中获取地址。
这是 google 搜索 Indy TIdMessage
的第二个项目。
例如:
function GetEmailAddresses(const Email: TIdMessage): TStringList;
var
Item: TIdEmailAddressItem;
begin
Result := TStringList.Create;
for Item in Email.Recipients do Result.Add(Item.Address);
for Item in Email.CcList do Result.Add(Item.Address);
for Item in Email.BccList do Result.Add(Item.Address);
end;
请注意 Indy 文档经常使用 with
关键字。
虽然方便,但 using with
is a very bad idea 我建议您不惜一切代价避免使用它。
如何使用 Indy 提取 TIdMessage
的 To
、Cc
和 Bcc
字段中存在的所有电子邮件地址?由于这些字段可以包含多个地址,我必须解析它们,但我没有找到任何现成的函数(也许我错过了?)。
你显然没有阅读
TIdMessage.Recipients
Identifies the recipients of a message.
property Recipients: TIdEmailAddressList;
Description
Recipients is aTIdEMailAddressList
property used to storeTIdEmailAddressItem
values that identify the recipients of the message. UseCCList
for recipients to receive a Carbon Copy of the message. UseBCCList
for recipients to receive a Blind Carbon Copy of the message.
所有这些属性都为您提供了一个 TIdEmailAddressList
,您可以从中获取地址。
这是 google 搜索 Indy TIdMessage
的第二个项目。
例如:
function GetEmailAddresses(const Email: TIdMessage): TStringList;
var
Item: TIdEmailAddressItem;
begin
Result := TStringList.Create;
for Item in Email.Recipients do Result.Add(Item.Address);
for Item in Email.CcList do Result.Add(Item.Address);
for Item in Email.BccList do Result.Add(Item.Address);
end;
请注意 Indy 文档经常使用 with
关键字。
虽然方便,但 using with
is a very bad idea 我建议您不惜一切代价避免使用它。