I can't really know what's wrong with my code, plz I need help, thx
the Words underlined here, r underlined in Delphi(error)
the Words underlined here, r underlined in Delphi(error)
Code:
unit mailer;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase,
IdSMTP;
type
TForm3 = class(TForm)
edTo: TEdit;
edFrom: TEdit;
edSubject: TEdit;
edCC: TEdit;
edBC: TEdit;
Memo1: TMemo;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
lvAttachments: TListBox;
btBrowse: TButton;
btMsg: TButton;
CheckBox1: TCheckBox;
OpenDialog1: TOpenDialog;
Label6: TLabel;
IdSMTP1: TIdSMTP;
IdMessage1: TIdMessage;
procedure btMsgClick(Sender: TObject);
procedure btBrowseClick(Sender: TObject);
procedure AddAttachments;
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form3: TForm3;
implementation
uses idreplysmtp;
{$R *.dfm}
procedure Tform3.AddAttachments;
var li: [U]TListItem[/U];
idx: Integer;
//clear the attachment listview
lvAttachments.[U]Items[/U].Clear;
//loop through Idmessage and count parts
for idx := 0 to Pred(Idmessage.MessageParts.Count) do
begin
li := lvAttachments.Items.Add;
// Check if Idmessage contains any attachments…
if Idmessage.[U]MessageParts[/U].Items[idx] is TIdAttachmentFile then
begin
//if so, get the file names…
li.[U]Caption [/U] :=
[U]TIdAttachmentFile[/U](Idmessage.MessageParts.Items[idx]).Filename;
//and add them to the listview li.SubItems.Add(TIdAttachmentFile(Idmessage.MessageParts.Items[idx]).ContentType);
end
else
begin
li.[U]Caption [/U] := Idmessage.MessageParts.Items[idx].Content[U]Type[/U];
end;
end;
end;
procedure TForm3.[U]btBrowseClick[/U](Sender: TObject);
begin
if opendialog.Execute then
TIdAttachmentFile.Create(idmessage.MessageParts,
opendialog.FileName);
AddAttachments;
end;
procedure TForm3.btMsgClick(Sender: TObject);
begin
//setup idSMTP connection parameters
idSMTP.Host :=your host name;
idSMTP.Port := 25; //smtp service usually
runs on this port
idSMTP.Password:=your password;
end;
//setup
idmessage parameters
idmessage.From.address:=edFrom.Text;
idmessage.Recipients.EMailAddresses:=edTo.Text;
idmessage.CCList.EMailAddresses:=edCC.Text;
idmessage.BccList.EMailAddresses:=edBC.Text;
idmessage.Subject :=edSubject.Text;
idmessage.Body.Text := memo1.Lines.Text;
//check if receipt confirmation is required
if checkbox1.checked then
//if required, set the sendback email
address to your email address
idmessage.ReceiptRecipient.Text:=edfrom.Text;
//send the message
try
try
idSMTP.Connect;
idSMTP.send(idmessage);
//if an exception occurs…
except on E: EIdSMTPReplyError do
begin
//…then show the message
ShowMessage(E.Message);
end;
end;
finally
//disconnect from server
if IdSMTP.Connected then
IdSMTP.Disconnect;
end;
end;
end.
Comment