2014-04-08 2 views
1

OnRetrieve 이벤트를 통해 TIdPOP3Server 인디 10에 텍스트 파일을 보내는데 문제가 없지만 여러 파일을 보내는 방법을 모르겠습니다.TIdPOP3Server로 일부 [텍스트] 파일로 이메일 보내기

if MsgDecode.MessageParts[i] Is TIdAttachment then begin 
    (MsgDecode.MessageParts[i] as TIdAttachment).SaveToFile((MsgDecode.MessageParts[j] as TIdAttachment).FileName); 

사람이이 문제를 좀 도와 줄래 : 나는,하지만 어떻게 사람 다음과 같이 전송 된 파일을 읽을 수 있습니다 내 POP3 클라이언트 내 TIdPOP3Server.OnRetrieve 이벤트에서 TIdAttachment을 보낼 수는 TIdMessageTIdAttachment 달성되는 SMTP와 참조 ?

이 내 OnRetrieve 이벤트 :

procedure POP3ServerRetrieve(aCmd: TIdCommand; AMsgNo: Integer); 
If (AMsgNO >= 1) AND (AMsgNo<=myMailsCount) then begin 
aCmd.SendReply; 
aCmd.Response.LoadFromFile('mail_filename'); 
aCmd.Response.LoadFromFile('mail_attachment_filename_1'); 
// ... loading N attachments 
end 
Else aCmd.Reply.SetReply(ERR,Format(' -Message %d Does not exist.',[AMsgNO])); 
+0

당신의'OnRetreive' 이벤트 핸들러 코드를 제시해주십시오. 'TIdMessage'를 사용하여 이메일을 클라이언트에게 보냅니 까? 'TIdMessage'는 SMTP에서와 마찬가지로 POP3에서도 동일한 방식으로 작동합니다. 'TIdMessage'를 사용하지 않는다면 대신 MIME을 수동으로 처리해야합니다. –

+0

이것은 내 OnRetrieve 이벤트입니다. 프로 시저 POP3ServerRetrieve (aCmd : TIdCommand; AMsgNo : Integer); (AMsgNO> = 1) AND (AMsgNo <= myMailsCount)이면 aCmd.SendReply를 시작하십시오. aCmd.Response.LoadFromFile ('mail_filename'); aCmd.Response.LoadFromFile ('mail_attachment_filename_1'); // N 첨부 파일로드 중 end Else aCmd.Reply.SetReply (ERR, Format ('-Message % d does not exist.', [AMsgNO])); –

+0

@RemyLebeau, TIdCommand (POP3ServerOnRetrieve 이벤트의 첫 번째 인수)를 통해 TIdMessage를 보내는 방법에 대한 예제를 제공 할 수 있습니까? –

답변

1

대신이 시도 :

procedure POP3ServerRetrieve(aCmd: TIdCommand; AMsgNo: Integer); 
var 
    Msg: TIdMessage; 
    Stream: TMemoryStream; 
begin 
    if (AMsgNO >= 1) AND (AMsgNo <= myMailsCount) then 
    begin 
    Stream := TMemoryStream.Create; 
    try 
     Msg := TIdMessage.Create; 
     try 
     // fill Msg as needed ... 
     Msg.SaveToStream(Stream); 
     finally 
     Msg.Free; 
     end; 
     aCmd.Reply.SetReply(OK, 'message follows'); 
     aCmd.SendReply; 
     aCmd.Connection.IOHandler.Write(Stream); 
    finally 
     Stream.Free; 
    end; 
    end 
    else 
    aCmd.Reply.SetReply(ERR, Format('Message %d Does not exist.', [AMsgNO])); 
end; 
+0

고마워요. 당신은 나에게 큰 시간을 도왔다 :) –

관련 문제