下面是我用Idsmtp发送邮件的部分代码:
if IniReadBool('MailBox','LOGCHECK',False) then
begin
IdSmtp1.AuthenticationType:=atLogin;
idSmtp1.Username:= Trim(IniReadString('MailBox','MAILADDR',''));
idSmtp1.Password:= Trim(IniReadString('MailBox','PASSWORD','')); (form1.ADS_Cw_mail.FieldByName('pwd').asstring);
end
else
begin
IDSmtp1.AuthenticationType:=atNone;
end;
idsmtp1.Host:=Trim(IniReadString('MailBox','SMTP',''));
(form1.ADS_Cw_mail.FieldByName('smtp').asstring);
idsmtp1.Port:=25;
try
for i:=0 to edAttach.Items.Count-1 do
begin
TIDAttachment.Create(Idmessage1.MessageParts,edAttach.items.strings[i]);
end;
IdMessage1.Body.Clear;
IdMessage1.Body.Assign(edBody.lines);
IDMessage1.From.Address:=idSmtp1.Username;
IdMessage1.Recipients.EMailAddresses:=trim(edTo.text);
with IdMessage1.Recipients.Add do Address := edTo.Text;
if edCC.text<>'' then
with IdMessage1.CCList.Add do Address := edCC.Text;
IdMessage1.Subject:=edTopic.text;
Idmessage1.Date:=Now;
Idsmtp1.Connect(10000);
Idsmtp1.Send(IdMessage1);
if IniReadBool('MailBox','LOGCHECK',False) then
begin
IdSmtp1.AuthenticationType:=atLogin;
idSmtp1.Username:= Trim(IniReadString('MailBox','MAILADDR',''));
idSmtp1.Password:= Trim(IniReadString('MailBox','PASSWORD','')); (form1.ADS_Cw_mail.FieldByName('pwd').asstring);
end
else
begin
IDSmtp1.AuthenticationType:=atNone;
end;
idsmtp1.Host:=Trim(IniReadString('MailBox','SMTP',''));
(form1.ADS_Cw_mail.FieldByName('smtp').asstring);
idsmtp1.Port:=25;
try
for i:=0 to edAttach.Items.Count-1 do
begin
TIDAttachment.Create(Idmessage1.MessageParts,edAttach.items.strings[i]);
end;
IdMessage1.Body.Clear;
IdMessage1.Body.Assign(edBody.lines);
IDMessage1.From.Address:=idSmtp1.Username;
IdMessage1.Recipients.EMailAddresses:=trim(edTo.text);
with IdMessage1.Recipients.Add do Address := edTo.Text;
if edCC.text<>'' then
with IdMessage1.CCList.Add do Address := edCC.Text;
IdMessage1.Subject:=edTopic.text;
Idmessage1.Date:=Now;
Idsmtp1.Connect(10000);
Idsmtp1.Send(IdMessage1);
打开它,搜索Values['X-Library']
把它所在的行注释掉,保存,重新编译Indy包,
ok
呵呵