var
SMTP_HOST :
string = '
mail.gmx.net';
POP3_HOST :
string = '
pop.gmx.net';
USERNAME :
string = '
';
// wichtig bei gmx die kundennr
PASSWORD :
string = '
*****';
FROM_ADRESS :
string = '
email@gmx.de';
TO_ADRESS :
string = '
email@gmx.de';
function Tmain1.SendEmail(Recipient:
string;CCList:
string;sSubject:
string;Body:TStringList):boolean;
begin
idSMTP.Host := SMTP_HOST;
idSMTP.Username := USERNAME;
idSMTP.Password := PASSWORD;
idMessage.From.text := FROM_ADRESS;
idMessage.Sender.text:= idMessage.From.text;
idMessage.Recipients.EMailAddresses:= Recipient;
idMessage.CCList.EMailAddresses := CCList;
idMessage.Subject:=sSubject;
idMessage.Body.Clear;
idMessage.Body := Body;
try
idSMTP.Connect;
idSMTP.Send(idMessage);
idSMTP.Disconnect;
result:=True;
except on E :
Exception do
begin
if idSMTP.connected
then try idSMTP.disconnect;
except end;
result := false;
end;
end;
end;
{email senden }
procedure TForm1.Button1Click(Sender: TObject);
begin
IdPOP3.Host := POP3_HOST;
IdPOP3.Username := USERNAME;
IdPOP3.Password := PASSWORD;
IdPOP3.Connect(-1);
if IdPOP3.Connected = TRUE
then begin
st := TStringList.Create;
st.Text := eMailMemo.Lines.Text;
Main1.SendEmail(TO_ADRESS, '
', '
Betreff', st);
st.Free;
IdPOP3.Disconnect;
end;
end;