안녕하세요!
고수님들의 도움이 필요하여 이렇게 글을 올립니다.
Indy로 만든 ISAPI인데, 첨부하지 않으면 잘 가는데 첨부하면 에러가 발생되네요!
아래와 같습니다.
procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
SenderName, SenderEmail, Receiver, AttachFile, title, comments : string;
html : string;
mBody : TStrings;
begin
try
if Request.Method = 'POST' then
begin
with Request.ContentFields do
begin
SenderName := Values['edSender'];
SenderEmail := Values['edSenderEmail'];
Receiver := Values['edReceiver'];
AttachFile := Values['edAttachfile'];
title := Values['edTitle'];
comments := Values['edComments'];
end;
end else
begin
with Request.QueryFields do
begin
SenderName := Values['edSender'];
SenderEmail := Values['edSenderEmail'];
Receiver := Values['edReceiver'];
AttachFile := Values['edAttachfile'];
title := Values['edTitle'];
comments := Values['edComments'];
end;
end;
if AttachFile <> '' then
begin
TIdAttachment.Create(IdMsgSend.MessageParts, AttachFile); //파일 첨부
end;
with IdMsgSend do
begin
mBody := TStringList.Create;
mBody.Add(comments);
Body.Assign(mBody);
From.Text := Receiver;
Recipients.EMailAddresses := SenderEmail;
Subject := title;
mBody.free;
end;
SMTP.UserID := 'freelab';
SMTP.Password := '1122';
SMTP.Host := 'www.wjt.co.kr';
SMTP.Port := 25;
SMTP.Connect;
try
SMTP.Send(IdMsgSend);
finally
SMTP.Disconnect;
end;
html := LoadFile(localpath+'warning.htm');
replace(html,'@title','메일 발송 성공');
replace(html,'@logo','conglogo.gif');
replace(html,'@message','성공적으로 발송하였습니다.
또 작성하시겠습니까?');
Response.Content := html;
except
html := LoadFile(localpath+'warning.htm');
replace(html,'@title','메일 전송실패');
replace(html,'@logo','errorlogo.gif');
replace(html,'@message','메일전송에 실패했습니다.
다시 시도해주세요'
+'

');
Response.Content := html;
end;
end;