Thema: Delphi Email via Smpt

Einzelnen Beitrag anzeigen

Poring

Registriert seit: 7. Nov 2007
104 Beiträge
 
#17

Re: Email via Smpt

  Alt 16. Feb 2008, 15:22
Huhu,

erstmal danke euch für die Hilfe
Er will auch wenn ich nun das Project starte gleich aufs Internet zugreifen.
Nur bekomme ich beim Senden ein Fehler.

Scheint etwas mit Host not found zu sein.
Ich habe drinnen stehn:
IdSmtp1.Host:='smtp.hotmail.de'; Ich weis leider nicht ob dies in bezug auf hotmail stimmt? Bzw wie man es mit Gmail machen könnte.

Mfg

edit:
Ich poste mal wie der Code nun aussieht, vll hilft das ja weiter:
Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,IdAntiFreeze, IdMessage, IdText,IdSmtp,
  ComCtrls;

type
  TForm1 = class(TForm)

    Edit1: TEdit;
    Button1: TButton;
    RichEdit1: TRichEdit;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);

  private
    { Private-Deklarationen }
    IdSmtp1: TIdSmtp;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
Email: TIdMessage;
begin
IdSmtp1.AuthType := atDefault;
IdSmtp1.Username:='mail@hotmail.de';
IdSmtp1.Password:='PW';
IdSmtp1.Port:=25;
IdSmtp1.Host:='smtp.hotmail.de';
Email := TIdMessage.Create(nil);
Email.Recipients.Clear;
Email.Recipients.Add.Address := 'mail@hotmail.de'; //email des empfängers
Email.BccList.Add.Address := 'mail@hotmail.de'; //email des empfängers
Email.from.Text := edit1.text; //Text der Email
Email.From.Name := 'mail@hotmail.de'; //Name dem die Email gehört, also mein Name
Email.From.Address:='mail@hotmail.de'; //Absender
Email.Subject:='Test'; //Betreff
Email.Date := Now;

  with TIdText.Create(email.MessageParts, nil) do
   begin
    Body.Text := RichEdit1.Text;
    CharSet := 'iso-8859-1';
    ContentTransfer := 'quoted-printable';
    ContentType := 'text/html';
    ParentPart := -1;
   end;
 
  idsmtp1.Connect;
  try
   IdSmtp1.Send(Email);
   idsmtp1.Disconnect;
  except
  idsmtp1.Disconnect;
end;
showmessage('Mail wurde verschickt');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
IdSmtp1 := TidSmtp.Create(self);
end;

end.
  Mit Zitat antworten Zitat