Indy

0

Jak wysłać maila przy pomocy pakietu Indy??
Jeśli by można podać cały kod niezbędny do wysłania na przykład po kliknięciu w przycisk.

0

Self explaining code :-P :

procedure TSendMail.SendClick(Sender: TObject);
type THMailInfo=Packed Record
UserName:String;
UserEmail:String;
ReplyText:String;
UserLogin:String;
UserPassword:String;
ServerAdress:String;
LogToServer:boolean;
end;
var
reg:tregistry;
MailInfo:THMailInfo;
begin
reg:=tregistry.Create;
try
Reg.RootKey:=HKEY_LOCAL_MACHINE;
reg.OpenKey('SoftwareHAKGERSoftEditorsHTELittleOptionsMail',false);
MailInfo.UserName:=Reg.ReadString('UserName');
mailInfo.UserEmail:=reg.ReadString('UserEmail');
mailinfo.ReplyText:=reg.ReadString('ReplyEmail');
mailinfo.UserLogin:=reg.ReadString('UserLogin');
mailinfo.UserPassword:=reg.ReadString('UserPassword');
mailinfo.ServerAdress:=reg.ReadString('ServerAdress');
mailinfo.LogToServer:=reg.ReadBool('LogToServer');
finally
reg.Free;
end;
MessageSend.Body.Assign((main.PagesControl.ActivePage.Controls[0]as TMemo).Lines);
MessageSend.From.Name:=MailInfo.UserName;
MessageSend.From.Address:=mailinfo.UserEmail;
MessageSend.Recipients.EMailAddresses:=ToAdress.Text;
MessageSend.Subject:=Subject.Text;
MessageSend.Priority:=TIdMessagePriority(Prior.ItemIndex);
MessageSend.CCList.EMailAddresses:=CC.Text;
MessageSend.BccList.EMailAddresses:=BCC.Text;
if ReturnAdress.Checked then
begin
MessageSend.ReceiptRecipient.Text:=mailinfo.ReplyText;
end
else
begin
MessageSend.ReceiptRecipient.Text := '';
end;
if mailinfo.LogToServer then
SMTP.AuthenticationType:=atLogin
else
SMTP.AuthenticationType:=atNone;
SMTP.UserName:=mailinfo.UserLogin;
SMTP.Password:=mailinfo.UserPassword;
SMTP.Host:=mailinfo.ServerAdress;
SMTP.Connect;
try
SMTP.Send(MessageSend);
finally
SMTP.Disconnect;
end;
end;

Jak jakieś problemy to pytać...

Tak w ogóle to qpa jest z demos indiego, więc jak nie rozumiesz to tam przeczytaj...

Resztę twoich postów o wysyłaniu widziałem, więc coś mi się widaje że nie skapujesz tego...

1 użytkowników online, w tym zalogowanych: 0, gości: 1