도와주세요
뭐가 잘못되었는지 정말 죽을 지경입니다.
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 의 내용
나의 처음
여러분 환영합니다 |