由于http://www.indyproject.org/Sockets/Demos/index.EN.aspx中给出的演示只将接收的流保存到文件中,因此我不知道如何有效地将该流作为邮件发送.
谁能教我如何做到这一点或指出一些更完整的例子?
Hea*_*are 13
以下是有关如何发送电子邮件的完整示例:
VAR SMTP : TIdSMTP;
VAR MSG : TIdMSG;
.
.
MSG:=TIdMSG.Create(NIL);
TRY
WITH MSG.Recipients.Add DO BEGIN
Name:='<Name of recipient>';
Address:='<Email address of recipient>'
END;
MSG.BccList.Add.Address:='<Email address of Blind Copy recipient>';
MSG.From.Name:='<Name of sender>';
MSG.From.Address:='<Email address of sender>';
MSG.Body.Text:='<Message Body>';
MSG.Subject:='<Subject of message>';
SMTP:=TIdSMTP.Create(NIL);
TRY
SMTP.Host:='x.x.x.x'; // IP Address of SMTP server
SMTP.Port:=25; // Port address of SMTP service (usually 25)
SMTP.Connect;
TRY
SMTP.Send(MSG)
FINALLY
SMTP.Disconnect
END
FINALLY
SMTP.Free
END
FINALLY
MSG.Free
END;
.
.
Run Code Online (Sandbox Code Playgroud)
(我知道WITH是不受欢迎的,但我通常在这样的情况下使用它,毫无疑问是什么,以及没有(或只是无限小)模糊的机会)