|
윤구 님이 쓰신 글 :
: 델파이에서 인디사용해서 메일 보내는 소스 입니다. 빌더에서 참고해서 만들려고 하는데요. 소스에서 다른거 대부분은 이해가 가는데 맨 아래쪽에 첨부파일 보내기 기능 구현을 위해 사용된 TIdAttachment라는게 있는데 빌더에서는 이걸 사용하려면 어떻게 해야 되는지 모르겠습니다. 뭘 인클루드 해야 되는지 알려주세요.
: 그냥 추측으로 TIdAttachment.hpp하니까 안되네요.
: unit uSMTPFrom;
:
: interface
:
: uses
: Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
: Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent,
: IdTCPConnection, IdTCPClient, IdMessageClient, IdSMTP, ExtCtrls,
: IdAntiFreezeBase, IdAntiFreeze;
:
: type
: TfrmSMTP = class(TForm)
: IdSMTP: TIdSMTP;
: IdMsg: TIdMessage;
: Panel1: TPanel;
: lblTo: TLabel;
: edtTo: TEdit;
: edtSubject: TEdit;
: lblSubject: TLabel;
: edtCc: TEdit;
: Label1: TLabel;
: Panel2: TPanel;
: Button1: TButton;
: Button2: TButton;
: Memo1: TMemo;
: IdAntiFreeze1: TIdAntiFreeze;
: Button3: TButton;
: ListBox1: TListBox;
: OpenDialog1: TOpenDialog;
: chkHtml: TCheckBox;
: procedure FormClose(Sender: TObject; var Action: TCloseAction);
: procedure Button2Click(Sender: TObject);
: procedure Button1Click(Sender: TObject);
: procedure Button3Click(Sender: TObject);
: private
: { Private declarations }
: public
: { Public declarations }
: procedure AttachmentPrint;
: end;
:
: var
: frmSMTP: TfrmSMTP;
:
: implementation
:
: uses uMainForm;
:
: {$R *.dfm}
:
: procedure TfrmSMTP.FormClose(Sender: TObject; var Action: TCloseAction);
: begin
: Action := caFree;
: end;
:
: procedure TfrmSMTP.Button2Click(Sender: TObject);
: begin
: Close;
: end;
:
: procedure TfrmSMTP.Button1Click(Sender: TObject);
: var
: textMsg: TIdText;
: begin
:
: IdMsg.Body.Assign( Memo1.Lines );
: IdMsg.From.Text := frmMain.edtEMailAddress.Text;
: IdMsg.Recipients.EMailAddresses := edtTo.Text;
: IdMsg.Subject := edtSubject.Text;
: IdMsg.CCList.EMailAddresses := edtCc.Text;
: IdSMTP.UserId := frmMain.edtUserId.Text;
: IdSMTP.Password := frmMain.edtPassword.Text;
: IdSMTP.Host := frmMain.edtSMTPHost.Text;
: IdSMTP.Connect;
:
: if chkHtml.Checked then // Html 형식으로 메일을 보낼때 ContentType = multipart/alternative 상태로 자동으로 처리된다.
: begin
: TIdText.Create( IdMsg.MessageParts, nil);
: textMsg := TIdText.Create( IdMsg.MessageParts, nil );
: textMsg.ContentType := 'text/html';
: textMsg.Body.Text := Memo1.Lines.Text;
: end;
: try
: IdSMTP.Send( IdMsg );
: finally
: IdSMTP.Disconnect;
: Close;
: end;
:
: end;
:
: procedure TfrmSMTP.AttachmentPrint;
: var
: i: Integer;
: begin
: ListBox1.Clear;
: for i := 0 to IdMsg.MessageParts.Count - 1 do
: ListBox1.Items.Add( TIdAttachment( IdMsg.MessageParts.Items[i] ).FileName ) // ContentType 이 multipart/alternative로 자동으로 처리된다.
: end;
:
: procedure TfrmSMTP.Button3Click(Sender: TObject);
: begin
: if OpenDialog1.Execute then
: begin
: //바로 이부분 뭘 인클루드해서 사용해야 하는지 알려주세요.
: TIdAttachment.Create( IdMsg.MessageParts, OpenDialog1.FileName );
: AttachmentPrint;
: end;
: end;
:
: end.
|