473,383 Members | 1,958 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Delphi 2007 SMTP send email

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)
Expand|Select|Wrap|Line Numbers
  1. unit mailer;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, StdCtrls, IdMessage, IdBaseComponent, IdComponent, IdTCPConnection,
  8.   IdTCPClient, IdExplicitTLSClientServerBase, IdMessageClient, IdSMTPBase,
  9.   IdSMTP;
  10.  
  11. type
  12.   TForm3 = class(TForm)
  13.     edTo: TEdit;
  14.     edFrom: TEdit;
  15.     edSubject: TEdit;
  16.     edCC: TEdit;
  17.     edBC: TEdit;
  18.     Memo1: TMemo;
  19.     Label1: TLabel;
  20.     Label2: TLabel;
  21.     Label3: TLabel;
  22.     Label4: TLabel;
  23.     Label5: TLabel;
  24.     lvAttachments: TListBox;
  25.     btBrowse: TButton;
  26.     btMsg: TButton;
  27.     CheckBox1: TCheckBox;
  28.     OpenDialog1: TOpenDialog;
  29.     Label6: TLabel;
  30.     IdSMTP1: TIdSMTP;
  31.     IdMessage1: TIdMessage;
  32.     procedure btMsgClick(Sender: TObject);
  33.     procedure btBrowseClick(Sender: TObject);
  34.     procedure AddAttachments;
  35.   private
  36.     { Private declarations }
  37.   public
  38.     { Public declarations }
  39.   end;
  40.  
  41. var
  42.   Form3: TForm3;
  43.  
  44. implementation
  45. uses idreplysmtp;
  46.  
  47. {$R *.dfm}
  48.  
  49.  
  50. procedure Tform3.AddAttachments;
  51. var li: TListItem;
  52. idx: Integer;
  53. //clear the attachment listview
  54. lvAttachments.Items.Clear;
  55. //loop through Idmessage and count parts
  56. for idx := 0 to Pred(Idmessage.MessageParts.Count) do
  57. begin
  58. li := lvAttachments.Items.Add;
  59. // Check if Idmessage contains any attachments…
  60.  
  61. if Idmessage.MessageParts.Items[idx] is TIdAttachmentFile then
  62. begin
  63. //if so, get the file names…
  64. li.Caption  :=
  65. TIdAttachmentFile(Idmessage.MessageParts.Items[idx]).Filename;
  66. //and add them to the listview li.SubItems.Add(TIdAttachmentFile(Idmessage.MessageParts.Items[idx]).ContentType);
  67. end
  68. else
  69. begin
  70. li.Caption  := Idmessage.MessageParts.Items[idx].ContentType;
  71. end;
  72. end;
  73. end;
  74.  
  75.  
  76.  
  77.  
  78. procedure TForm3.btBrowseClick(Sender: TObject);
  79. begin
  80. if opendialog.Execute then
  81. TIdAttachmentFile.Create(idmessage.MessageParts,
  82. opendialog.FileName);
  83. AddAttachments;
  84.  
  85. end;
  86.  
  87. procedure TForm3.btMsgClick(Sender: TObject);
  88. begin
  89.   //setup idSMTP connection parameters
  90. idSMTP.Host :=your host name;
  91. idSMTP.Port := 25; //smtp service usually
  92. runs on this port
  93. idSMTP.Password:=your password;
  94. end;
  95. //setup
  96. idmessage parameters
  97. idmessage.From.address:=edFrom.Text;
  98. idmessage.Recipients.EMailAddresses:=edTo.Text;
  99. idmessage.CCList.EMailAddresses:=edCC.Text;
  100. idmessage.BccList.EMailAddresses:=edBC.Text;
  101. idmessage.Subject :=edSubject.Text;
  102. idmessage.Body.Text := memo1.Lines.Text;
  103. //check if receipt confirmation is required
  104. if checkbox1.checked then
  105. //if required, set the sendback email
  106. address to your email address
  107. idmessage.ReceiptRecipient.Text:=edfrom.Text;
  108. //send the message
  109. try
  110. try
  111. idSMTP.Connect;
  112. idSMTP.send(idmessage);
  113. //if an exception occurs…
  114. except on E: EIdSMTPReplyError do
  115. begin
  116. //…then show the message
  117. ShowMessage(E.Message);
  118. end;
  119. end;
  120. finally
  121. //disconnect from server
  122. if IdSMTP.Connected then
  123. IdSMTP.Disconnect;
  124. end;
  125. end;
  126.  
  127. end.
Jul 30 '08 #1
1 6084
Stang02GT
1,208 Expert 1GB
I added code tags to your post.


When posting ANY code please make sure to utilize the [code] tags.



Thank You.
Jul 31 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
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...
9
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,...
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...
4
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...
2
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...
16
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...
16
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...
5
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...
14
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...
1
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...
0
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...
0
isladogs
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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$) { } ...
0
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...
0
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...
1
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.