Preferisco Indy perchè più completo per le mie neccessità posto il mio codice.
codice:
procedure TForm1.SpedisciClick(Sender: TObject);
begin
SMTP.Host := Server.Text;
SMTP.Port := StrToInt(ServerPort.Text);
if None.checked= true then begin
Smtp.AuthenticationType := atNone;
end;
if Login.checked= true then begin
Smtp.AuthenticationType := atLogin;
end;
SMTP.MailAgent := Agent.Text;
SMTP.HeloName:= Helo.Text;
if EhloAttivo.checked= True then begin
SMTP.UseEhlo:= True;
end;
if EhloDisattivato.checked= True then begin
SMTP.UseEhlo:= False;
end;
if Massima.checked= true then begin
MailMessage.Priority := TIdMessagePriority (mpHighest);
end;
if Alta.checked= true then begin
MailMessage.Priority := TIdMessagePriority (mpHigh);
end;
if Normale.checked= true then begin
MailMessage.Priority := TIdMessagePriority (mpNormal);
end;
if Bassa.checked= true then begin
MailMessage.Priority := TIdMessagePriority (mpLow);
end;
if Minima.checked= true then begin
MailMessage.Priority := TIdMessagePriority (mpLowest);
end;
MailMessage.From.Address := Da.Text;
MailMessage.From.Name := Nome.Text;
MailMessage.Organization := Org.Text;
MailMessage.Recipients.EMailAddresses :=
A.Text + ' ' + Lista.Text;
MailMessage.CCList.EMailAddresses := CC.Text;
MailMessage.BccList.EMailAddresses := Ccn.Text;
MailMessage.Subject := Oggetto.Text;
MailMessage.Body.Text := Messaggio.Text;
if FileExists(Allegato.Text) then
TIdAttachment.Create(MailMessage.MessageParts, Allegato.Text);
try
try
SMTP.Connect(10000);
SMTP.Send(MailMessage);
except on E:Exception do
ShowMessage('Errore: ' + E.Message);
end;
finally
if SMTP.Connected then
SMTP.Disconnect;
StatusBar.Panels[2].Text:='Email Inviata';
MessageBeep(20);
end;
end;