Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[15320] SMTP 사용법 (메일은 보내지는데 내용이 나타나지 않습니다.
이우석 [snr2000] 2770 읽음    2014-10-22 17:12
도와주세요
뭐가 잘못되었는지 정말 죽을 지경입니다.

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
  IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase, IdSMTP,
  IdAttachment, IdText, IdMessage;

type
  TForm1 = class(TForm)
    Button1: TButton;
    IdSMTP1: TIdSMTP;
    IdMessage1: TIdMessage;
    AttFileList: TListBox;
    Memo1: TMemo;    //<-- 본문내용
    Label1: TLabel;
    Label2: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var tomail,ccmail,bccmail:Tstrings;
    Saddress: string;
    i : integer;
    textMsg,htmpart,txtpart: TidText;
    idAttachment: TidAttachment;
    tc: Dword;
    UTFString: UTF8string;
begin
    idSMTP1.Host := 서버;
    idSMTP1.UserName := ;
    idSMTP1.Password := ;
    idSMTP1.Port := 25;
    if idSMTP1.Connected = false then
       idSMTP1.Connect;
  try
    idMessage1.clear;
    idMessage1.ClearBody;
    idMessage1.MessageParts.Clear;
    idMessage1.ClearHeader;
    idMessage1.From.Name    := '메일보내는사람이름';
    idMessage1.From.Address := ;
    idMessage1.ContentType  := 'text/html';
    idMessage1.CharSet      := 'ks_c_5601-1987';
    idMessage1.Headers.Add('Content-type: text/html'); //body본문네용(memo: Mbody_mail)
    idMessage1.Subject      := wideString('이것은테스트 메일이다'); //제목
    idMessage1.Recipients.Clear;
    idMessage1.CCList.Clear;
    idMessage1.BCCList.Clear;
    //to mamil information list------------------//
    idMessage1.Recipients.Add.Address := 메일 받는사람 메일주소;
    //------------------------------------------//
    //CC mailinformation List-------------------//
    idMessage1.CCList.Add.Address := '';        //참조메일주소;
    //------------------------------------------//
    //BCC amil information List-----------------//
    idMessage1.BccList.Add.Address := '';       //비밀 참조메일주소;
    //------------------------------------------//
    //HTML 형식으로 첨부파일 메일보낼때 [첨부파일 ListBox(Lattachment_mail)]
    if AttFileList.Items.Text <> '' then begin
      idMessage1.MessageParts.Clear;
      for i := 0 to AttFileList.Items.Count - 1 do begin
//        idAttachment := TidAttachment.Create(AttFileList.Items[i]);
      end;

      txtpart := TidText.Create(idMessage1.MessageParts);
      txtpart.ContentType := 'text/plain';

      htmpart := TidText.Create(idMessage1.MessageParts);
      // Attachments Case by Mime type -> chartset - UTF-8 인코딩해서 보낸다(변환필수)핵심
      UTFstring := UTF8Encode(WideString(memo1.Lines.Text)); // <----delphi 7 version 함수 
        
                                                                이부분입니다.


      htmpart.Body.Add(UTFString);
      htmpart.ContentType := 'text/html';
    end;
  finally
   idSMTP1.Send(idMessage1);
   if AttFileList.Items.Text < '' then begin
     txtpart.free;
     htmpart.free;
   end;
   idSMTP1.Disconnect();
  end;
  end;
end.



memo1.Lines.Text 의 내용

나의 처음

여러분 환영합니다


+ -

관련 글 리스트
15320 SMTP 사용법 (메일은 보내지는데 내용이 나타나지 않습니다. 이우석 2770 2014/10/22
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.