1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59:
| unit smtp_geht;
interface
uses inifiles,Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP,IdMessage, StdCtrls,ComCtrls, Buttons, ExtCtrls;
type TForm1 = class(TForm) Button1: TButton; IdSMTP1: TIdSMTP; IdMessage1: TIdMessage; procedure Button1Click(Sender: TObject); private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var msg: TIdMessage; begin msg := TIdMessage.Create(Self); with msg do begin Sender.Text := 'Absender'; Sender.Name := 'Sender'; Sender.DisplayName := 'Ich bin der Sender'; Recipients.EMailAddresses := 'e-mail an wen'; Body.Add('Text der Mail'); Subject := 'Testilein'; end;
TIdAttachment.Create(msg.MessageParts, 'C:/bla.txt'); with IdSMTP1 do begin Host := 'smtp.mail.yahoo.com'; AuthenticationType := atLogin; Username := 'user'; Password := 'Password';
Port := 25; Connect(); try Send(msg); except ShowMessage(IdSMTP1.LastCmdResult.TextCode+' - '+IdSMTP1.LastCmdResult.Text.Text); end; Disconnect; end; end; end. |