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 6115 Stang02GT 1,208
Recognized Expert Top Contributor
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 iMsg2 = CreateObject("CDO.Message")
|
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,
VisualStudio2002, VB as programing language. Our
test/development version of the web app as hosted on
our "localhost" works fine; our "Default SMTP Virtual
Server" is running (per the IIS console).
|
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 with this code:
MailMessage msgMail = new MailMessage();
msgMail.To = "test@address.com";
msgMail.From = "from@address.com";
msgMail.Subject = "Mail Example Subject";
|
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 without SMTP installed?
|
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 the problem? My code is as follows:
Dim objMail As New System.Net.Mail.MailMessage
'populage info
objMail.From = New MailAddress(“admin@mail.com”)
| |
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 environment: VS2005 + XP.-- I have disabled firewall
hardware enviornmnet:telcom's modem connects hub,hub connects two
computers.。-- I also tried to connect computer to modem directly,but I can
|
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 &
Listbox1.SelectedItem.Text) the smtp.Send fails. Any ideas ?
|
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 emaill addresses and send emails out.
the problem is that all of the email addresses the email is being sent to is showing in the section so everyone knows who's getting the email.
How can I have 1 email address showing in the section so no...
|
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 guide me to get it work?
Regards
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |