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) -
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: TListItem;
-
idx: Integer;
-
//clear the attachment listview
-
lvAttachments.Items.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.MessageParts.Items[idx] is TIdAttachmentFile then
-
begin
-
//if so, get the file names…
-
li.Caption :=
- TIdAttachmentFile(Idmessage.MessageParts.Items[idx]).Filename;
-
//and add them to the listview li.SubItems.Add(TIdAttachmentFile(Idmessage.MessageParts.Items[idx]).ContentType);
-
end
-
else
-
begin
-
li.Caption := Idmessage.MessageParts.Items[idx].ContentType;
-
end;
-
end;
-
end;
-
-
-
-
-
procedure TForm3.btBrowseClick(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.
1 6084
I added code tags to your post.
When posting ANY code please make sure to utilize the [code] tags.
Thank You.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Salim Afþar |
last post by:
Hi,
I'm using CDO object to send email but it doesn't send any email and it does
not give an error.
My code look like this:
Dim iMsg2
Dim iConf2
Dim Flds2
Const cdoSendUsingPort = 2
set...
|
by: Bob Jones |
last post by:
We have developed a commercial ASP.net application
(personal nutrition management and tracking); we want to
send smtp email from within it.
For our development box, we use WinXP Pro, IIS 5.5,...
|
by: Andreas |
last post by:
I am working with three computers, my developing computer, a Web Server and a
Mail Server (Exchange).
I am trying to send a email from the Web Server via the Mail Server to a
valid email address...
|
by: CLEAR-RCIC |
last post by:
I want to send an email from our Intranet site to myself whenever an error
happens. Our manager will not let us install SMTP on the web server. Is it
possible to send email programatically...
|
by: =?Utf-8?B?Y2hpZWtv?= |
last post by:
Hello,
I have Asp.net 2.0 app that needs to send an email. It works fine when the
app tries to send inside of the network, but I can’t send email outside.
Does anyone know how I can resolve...
|
by: =?Utf-8?B?Q2hlZg==?= |
last post by:
I can use outlook2003 to send email,but I cann't use this code below to send
email.
Please help me to test this code and instruct me how to solve this problem
in detail.
software...
|
by: bgreer5050 |
last post by:
I have a form with the following fields:
UserEmail
Subject
Body
When the form is submitted, the email is processed fine. When I try
to add another field to the mm.body (mm.Body = Body.Text...
|
by: Mike |
last post by:
I have a page with a textbox that a user can enter in mutliple email addresses such as:
user1@yahoo.com;user2@yahoo.com;user3@gmail.com;
and so on, I then have a foreach loop to get all of the...
|
by: Warren Tang |
last post by:
Hi
I am using the mail function to send a mail like this:
$b = mail("my_real_email_address@gmail.com", "Hello from PHP",
"Hi, finally sent an email successfully");
But it failed. Could you...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |