Newsgroups : Borland : borland.public.delphi.internet.winsock : 2008 Feb : Re: Internal Application Error
| Subject: | Re: Internal Application Error |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Tue, 5 Feb 2008 13:44:04 |
"mark horrocks" <markhorrocks@yahoo.com> wrote in message
news:47a865d8@newsgroups.borland.com...
> The app works fine, emails get sent Ok as expected, but the Response
> is never sent back, just a message that says Internal Application Error.
Then your code is crashing somewhere.
> Here is the code.
Try this:
procedure TWebModule1.WebModule1waSendMailAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
Msg: String;
begin
idSMTP.Host := 'mail.sportdata.com.au';
idSMTP.Port := 25; //smtp service usually runs on this port
idMessage.Clear;
idMessage.From.Address :=
Request.ContentFields.Values['FromAddress'];
idMessage.Recipients.EMailAddresses :=
Request.ContentFields.Values['FromAddress'];
idMessage.BccList.EMailAddresses :=
Request.ContentFields.Values['EmailAddresses'];
idMessage.Subject := Request.ContentFields.Values['Subject'];
idMessage.Body.Text := '<html><head></head><body>' + '<p>' +
Request.ContentFields.Values['AdditionalMessage'] +
Request.ContentFields.Values['BodyText'] +
'</body></html>';
idMessage.ContentType := 'text/html';
try
idSMTP.Connect;
try
idSMTP.Send(idMessage);
finally
IdSMTP.Disconnect;
end;
Msg := 'Email(s) sent successfully!';
except
on E: Exception do
Msg := E.Message;
end;
Response.Content := '<html><head></head><body><p>' + Msg +
'</body></html>';
end;
Gambit