const Host_Server_SMTP = 'smtp.mail.ru';
const Port_Server_SMTP = 25;
const SenderUserName = 'mylogin';
const SenderPassword = 'mypwd';
const SenderAddress = 'mylogin@mail.ru';
const RecipientAddress = 'yourbox@mail.ru';
........................................
........................................
with DataMailModule do
begin
IdSMTP1.Host := Host_Server_SMTP;
IdSMTP1.Port := Port_Server_SMTP;
IdSMTP1.Username := SenderUserName;
IdSMTP1.Password := SenderPassword;
IdMessage1.From.Address := SenderAddress;
IdMessage1.Subject := ExtractFileName(FileNameAttach);
IdMessage1.From.Address := SenderAddress;
IdMessage1.From.Text := 'For You';
IdMessage1.Body.Text := 'File : ' + ExtractFileName(FileNameAttach);
IdMessage1.Recipients.Add;
IdMessage1.Recipients.Items[0].Text := RecipientAddress;
TIdAttachmentFile.Create(IdMessage1.MessageParts, FileNameAttach);
try
IdSMTP1.Connect;
IdSMTP1.Authenticate;
IdSMTP1.Send(IdMessage1);
IdSMTP1.Disconnect;
except
on E: Exception do
begin
//ShowMessage('Чот не то.');
end;
end;
На строке
IdSMTP1.Send(IdMessage1);прога прекращает выполняться, начинается
except для нее.
Если написать
IdMessage1.From.Text := SenderAddress;то отправка проходит. Почему ?