Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to send a email message in ASP.NET using Delphi.net. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Send a email message in ASP.NET using Delphi.net. 04-Jul-05
Category
ASP.NET
Language
Delphi 8.x .NET
Views
246
User Rating
7
# Votes
1
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			1   
2   //This code shows how tto send email using asp.net in delphi.
3   unit WebForm1;
4   
5   interface
6   
7   uses
8     System.Collections, System.ComponentModel,
9     System.Data, System.Drawing, System.Web, System.Web.SessionState,
10    System.Web.UI, System.Web.UI.WebControls, System.Web.UI.HtmlControls,
11    System.Web.Mail;
12  
13  type
14    TWebForm1 = class(System.Web.UI.Page)
15    {$REGION 'Designer Managed Code'}
16    strict private
17      procedure InitializeComponent;
18      procedure Button1_Click(sender: System.object; e: System.EventArgs);
19    {$ENDREGION}
20    strict private
21      procedure Page_Load(sender: System.object; e: System.EventArgs);
22    strict protected
23      txtEmail: System.Web.UI.WebControls.TextBox;
24      txtSubject: System.Web.UI.WebControls.TextBox;
25      txtMessage: System.Web.UI.WebControls.TextBox;
26      Button1: System.Web.UI.WebControls.Button;
27      procedure OnInit(e: EventArgs); override;
28    private
29      { Private Declarations }
30    public
31      { Public Declarations }
32    end;
33  
34  implementation
35  
36  {$REGION 'Designer Managed Code'}
37  /// <summary>
38  /// Required method for Designer support -- do not modify
39  /// the contents of this method with the code editor.
40  /// </summary>
41  procedure TWebForm1.InitializeComponent;
42  begin
43    Include(Self.Button1.Click, Self.Button1_Click);
44    Include(Self.Load, Self.Page_Load);
45  end;
46  {$ENDREGION}
47  
48  procedure TWebForm1.Page_Load(sender: System.object; e: System.EventArgs);
49  begin
50    // TODO: Put user code to initialize the page here
51  end;
52  
53  procedure TWebForm1.OnInit(e: EventArgs);
54  begin
55    //
56    // Required for Designer support
57    //
58    InitializeComponent;
59    inherited OnInit(e);
60  end;
61  
62  procedure TWebForm1.Button1_Click(sender: System.object; e: System.EventArgs);
63  var 
64   mmEmail : MailMessage;
65  begin
66  mmEmail  := MailMessage.Create;
67  mmEmail.From := 'test@test.com';
68  mmEmail.to  := txtEmail.Text;
69  mmEmail.Bcc    := 'who@whatever.com';
70  mmEmail.Subject := txtSubject.Text;
71  mmEmail.BodyFormat := MailFormat.HTML;
72  mmEmail.Body := txtMessage.Text;
73  //Gets or sets the name of the SMTP relay mail server to use to send e-mail
74  //messages.
75  SmtpMail.SmtpServer := 'localhost';//change host to your smtp server.
76  SmtpMail.Send(mmEmail);
77  
78  
79  end;
80  
81  end.



			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC