il codice che devi usare è questo
codice:
procedure TMailerForm.btnSendMailClick(Sender: TObject);
begin
StatusMemo.Clear;
//setup SMTP
SMTP.Host := ledHost.Text;
SMTP.Port := 25;
//setup mail message
MailMessage.From.Address := ledFrom.Text;
MailMessage.Recipients.EMailAddresses :=
ledTo.Text + ',' + ledCC.Text;
MailMessage.Subject := ledSubject.Text;
MailMessage.Body.Text := Body.Text;
if FileExists(ledAttachment.Text) then
TIdAttachment.Create(MailMessage.MessageParts,
ledAttachment.Text);
//send mail
try
try
SMTP.Connect(1000);
SMTP.Send(MailMessage);
except on E:Exception do
StatusMemo.Lines.Insert(0, 'ERROR: ' + E.Message);
end;
finally
if SMTP.Connected then
SMTP.Disconnect;
end;
end; (* btnSendMail Click *)
Dopo aver inserito i due componenti
To send an email with attachment(s) from Delphi using Indy, we'll need two components. First, the TIdSMTOP is used to connect and communicate (send mail) with an SMTP server. Second, the TIdMessage handles storing and encoding of message(s).
When the message is constructed (TIdMessage "filled" with data), the email message is delivered to an SMTP server using the TIdSMTP.
l'host è il tuo server di posta.
Se vuoi ti crei una dialog box come in figura, altrimenti li compili da codice.
ciao
sergio