Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unit Unit1;
- interface
- uses
- Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, smtpsend, winsock,
- Dialogs,blcksock,synautil,synacode, Buttons;
- type
- TForm1 = class(TForm)
- SpeedButton1: TSpeedButton;
- procedure SpeedButton1Click(Sender: TObject);
- procedure FormCreate(Sender: TObject);
- private
- { Private declarations }
- public
- function SendEmailNotification(EventText : string): boolean;
- function myIPadd: string;
- end;
- TNotificationThread = class(TThread)
- public
- procedure Execute; override;
- end;
- var
- Form1: TForm1;
- emailmsg : TStrings;
- emlform, emlto, emlhost, emlusername, emlpassword : string;
- implementation
- {$R *.dfm}
- function TForm1.myIPadd: string;
- type
- TaPInAddr = array [0..10] of PInAddr;
- PaPInAddr = ^TaPInAddr;
- var
- phe : PHostEnt;
- pptr : PaPInAddr;
- Buffer : array [0..63] of char;
- i : Integer;
- GInitData : TWSADATA;
- begin
- WSAStartup($101, GInitData);
- Result := '';
- GetHostName(Buffer, SizeOf(Buffer));
- phe :=GetHostByName(buffer);
- if phe = nil then Exit;
- pptr := PaPInAddr(Phe^.h_addr_list);
- i := 0;
- while pptr^[i] <> nil do
- begin
- result:=StrPas(inet_ntoa(pptr^[i]^));
- Inc(i);
- end;
- WSACleanup;
- end;
- function TForm1.SendEmailNotification(EventText : string): boolean;
- var
- emailmsg : TStrings;
- emailsubject : string;
- sendresult : boolean;
- ipa : string;
- begin
- emailmsg := TStringList.Create;
- ipa := myIPadd;
- with emailmsg do
- begin
- Add('Hi');
- Add('');
- Add('This is a message from the Lyracon Server at '+ipa);
- Add('');
- Add(EventText);
- Add('');
- Add('Many thanks');
- Add('');
- Add('Lyrcacon Server');
- end;
- emailsubject := 'Activation Notification From Lyracon At '+ipa;
- sendresult := SendToEx(emlform, emlto, emailsubject, emlhost, emailmsg, emlusername, emlpassword);
- result := sendresult;
- end;
- procedure TNotificationThread.Execute;
- begin
- Form1.SendEmailNotification('THIS IS A THREADED EMAIL');
- end;
- procedure TForm1.SpeedButton1Click(Sender: TObject);
- begin
- TNotificationThread.Create(false);
- end;
- procedure TForm1.FormCreate(Sender: TObject);
- begin
- emlform := 'from@hdomain.com';
- emlto := 'to@domain.co.uk';
- emlhost := 'myemailserver';
- emlusername := 'user@server.co.uk';
- emlpassword := 'myemailpassword';
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement