使用OUTLOOK可以收信件发信件,但是用IDSMTP无法发送信件,好象对方收不到这边显示成功procedure TForm1.Button1Click(Sender: TObject);
var
IdMessage: TIdMessage;
IdSMTP: TIdSMTP;
Message: TStrings;
i: Integer;
Fichiers: Array Of String;
begin
IdMessage := TIdMessage.Create(nil); IdMessage.From.Address := '[email protected]; IdMessage.ReplyTo.Add.Address := '[email protected]';
IdMessage.Recipients.Add.Address := '[email protected]' ; IdMessage.Subject := 'Sujet du message'; IdMessage.ContentType := 'multipart/alternative'; Message := Memo1.Lines;
With TIdText.Create(IdMessage.MessageParts, Message) Do
Begin
ContentType := 'text/plain';
Body.Insert(0, 'Ce message est un message HTML... Configurez votre client de courrier électronique' +
'pour le visionner de manière appropriée');
end; with TIdText.Create(IdMessage.MessageParts, Message) do
ContentType := 'text/html'; for i := Low(Fichiers) to High(Fichiers) do
TIdAttachment.Create(IdMessage.MessageParts, Fichiers[i]); IdSMTP := TIdSMTP.Create(nil) ; //Création dynamique du composant
IdSMTP.Port := 25; //Le port SMTP standard…
IdSMTP.Host := 'mail.csu-pm.com'; //Le serveur auquel se connecter
IdSMTP.AuthenticationType := atLogin;
IdSMTP.Username := '[email protected]';
IdSMTP.Password := 'tomato*****';
Try
Try
IdSMTP.Connect;
IdSMTP.Send(IdMessage);
except
on e: exception do MessageDlg(e.Message, mtError, [mbOK], 0);
end;
finally
IdSMTP.Disconnect;
IdSMTP.Free;
IdMessage.Free;
end;end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货