By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,241 Members | 799 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,241 IT Pros & Developers. It's quick & easy.

Problem in Senting E-Mail using the SmtpMail

P: n/a
Hi !

I wrote one code for Send the E-mail, But that code have some problem , So please help me

Here i paste my code and Error:
Error:
Server Error in '/Elan_Sample' Application.
--------------------------------------------------------------------------------

The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.

Source Error:
Line 36: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 37: SmtpMail.SmtpServer = "trainee2.com" ' Trainee2.com is my SMTP Name
Line 38: SmtpMail.Send(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text)
Line 39: End Sub
Line 40: End Class

Source File: C:\Project Files\Root\Elan_Sample\Email Server.aspx.vb Line: 38

Stack Trace:
[COMException (0x80040213): The transport failed to connect to the server.
]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String methodName, Object[] args) +58

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String methodName, Object[] args) +112
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1840
System.Web.Mail.CdoSysHelper.Send(String from, String to, String subject, String messageText) +74
System.Web.Mail.SmtpMail.Send(String from, String to, String subject, String messageText) +171
Elan_Sample.Email_Server.Button1_Click(Object sender, EventArgs e) in C:\Project Files\Root\Elan_Sample\Email Server.aspx.vb:38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277




ASP.NET Script :

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Email Server.aspx.vb" Inherits="Elan_Sample.Email_Server"%>
OCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<title>Email_Server</title>

<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">

<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">

<meta name="vs_defaultClientScript" content="JavaScript">

<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

</HEAD>

<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<asp:TextBox id="txtFrom" style="Z-INDEX: 100; LEFT: 190px; POSITION: absolute; TOP: 62px" runat="server"></asp:TextBox>

<asp:Label id="Label8" style="Z-INDEX: 113; LEFT: 99px; POSITION: absolute; TOP: 212px" runat="server" Width="68px" Height="19px">Body</asp:Label>

<asp:Label id="Label7" style="Z-INDEX: 112; LEFT: 99px; POSITION: absolute; TOP: 156px" runat="server" Width="68px" Height="19px">Subject</asp:Label>

<asp:Label id="Label6" style="Z-INDEX: 111; LEFT: 99px; POSITION: absolute; TOP: 109px" runat="server" Width="68" Height="19">To</asp:Label>

<asp:TextBox id="txtBody" style="Z-INDEX: 109; LEFT: 192px; POSITION: absolute; TOP: 210px" runat="server"></asp:TextBox>

<asp:Label id="Label4" style="Z-INDEX: 102; LEFT: 126px; POSITION: absolute; TOP: 64px" runat="server">Label</asp:Label>

<asp:TextBox id="txtSubject" style="Z-INDEX: 108; LEFT: 193px; POSITION: absolute; TOP: 157px" runat="server"></asp:TextBox>

<asp:Label id="Label3" style="Z-INDEX: 101; LEFT: 126px; POSITION: absolute; TOP: 64px" runat="server">Label</asp:Label>

<asp:TextBox id="txtTo" style="Z-INDEX: 107; LEFT: 192px; POSITION: absolute; TOP: 106px" runat="server"></asp:TextBox>

<asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 126px; POSITION: absolute; TOP: 64px" runat="server">Label</asp:Label>

<asp:Label id="Label1" style="Z-INDEX: 104; LEFT: 99px; POSITION: absolute; TOP: 64px" runat="server" Width="68px" Height="19px">Form</asp:Label>

<asp:Button id="Button1" style="Z-INDEX: 106; LEFT: 291px; POSITION: absolute; TOP: 276px" runat="server" Text="Sent" Width="65px"></asp:Button>

</form>

</body>

</HTML>

Server side Script:

Imports System.Web.Mail

Public Class Email_Server

Inherits System.Web.UI.Page

Protected WithEvents txtFrom As System.Web.UI.WebControls.TextBox

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents txtTo As System.Web.UI.WebControls.TextBox

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents txtSubject As System.Web.UI.WebControls.TextBox

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents txtBody As System.Web.UI.WebControls.TextBox

Protected WithEvents Label6 As System.Web.UI.WebControls.Label

Protected WithEvents Label7 As System.Web.UI.WebControls.Label

Protected WithEvents Label8 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

SmtpMail.SmtpServer = "trainee2.com" ' Trainee2.com is my SMTP Name

SmtpMail.Send(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text)

End Sub

End Class

--------------------------------------------------------------------------
Thanks & Regards,
ElanKathir.S.N,
ASM Technologies,
B'lore.

Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

SMTP FAQ
http://www.asp.net/Forums/ShowPost.a...&PostID=268037

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"ElanKathir" <sn**********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Hi !

I wrote one code for Send the E-mail, But that code have some problem , So
please help me

Here i paste my code and Error:
Error:
Server Error in '/Elan_Sample' Application.
--------------------------------------------------------------------------------

The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The
transport failed to connect to the server.

Source Error:
Line 36: Private Sub Button1_Click(ByVal sender As System.Object, ByVal
e As System.EventArgs) Handles Button1.Click
Line 37: SmtpMail.SmtpServer = "trainee2.com" ' Trainee2.com is my
SMTP Name
Line 38: SmtpMail.Send(txtFrom.Text, txtTo.Text, txtSubject.Text,
txtBody.Text)
Line 39: End Sub
Line 40: End Class

Source File: C:\Project Files\Root\Elan_Sample\Email Server.aspx.vb Line:
38

Stack Trace:
[COMException (0x80040213): The transport failed to connect to the server.
]

[TargetInvocationException: Exception has been thrown by the target of an
invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr,
Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture,
String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args, ParameterModifier[] modifiers,
CultureInfo culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String
methodName, Object[] args) +58

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String
methodName, Object[] args) +112
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1840
System.Web.Mail.CdoSysHelper.Send(String from, String to, String subject,
String messageText) +74
System.Web.Mail.SmtpMail.Send(String from, String to, String subject,
String messageText) +171
Elan_Sample.Email_Server.Button1_Click(Object sender, EventArgs e) in
C:\Project Files\Root\Elan_Sample\Email Server.aspx.vb:38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277


ASP.NET Script :

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Email
Server.aspx.vb" Inherits="Elan_Sample.Email_Server"%>
OCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<title>Email_Server</title>

<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">

<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">

<meta name="vs_defaultClientScript" content="JavaScript">

<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">

</HEAD>

<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<asp:TextBox id="txtFrom" style="Z-INDEX: 100; LEFT: 190px; POSITION:
absolute; TOP: 62px" runat="server"></asp:TextBox>

<asp:Label id="Label8" style="Z-INDEX: 113; LEFT: 99px; POSITION: absolute;
TOP: 212px" runat="server" Width="68px" Height="19px">Body</asp:Label>

<asp:Label id="Label7" style="Z-INDEX: 112; LEFT: 99px; POSITION: absolute;
TOP: 156px" runat="server" Width="68px" Height="19px">Subject</asp:Label>

<asp:Label id="Label6" style="Z-INDEX: 111; LEFT: 99px; POSITION: absolute;
TOP: 109px" runat="server" Width="68" Height="19">To</asp:Label>

<asp:TextBox id="txtBody" style="Z-INDEX: 109; LEFT: 192px; POSITION:
absolute; TOP: 210px" runat="server"></asp:TextBox>

<asp:Label id="Label4" style="Z-INDEX: 102; LEFT: 126px; POSITION: absolute;
TOP: 64px" runat="server">Label</asp:Label>

<asp:TextBox id="txtSubject" style="Z-INDEX: 108; LEFT: 193px; POSITION:
absolute; TOP: 157px" runat="server"></asp:TextBox>

<asp:Label id="Label3" style="Z-INDEX: 101; LEFT: 126px; POSITION: absolute;
TOP: 64px" runat="server">Label</asp:Label>

<asp:TextBox id="txtTo" style="Z-INDEX: 107; LEFT: 192px; POSITION:
absolute; TOP: 106px" runat="server"></asp:TextBox>

<asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 126px; POSITION: absolute;
TOP: 64px" runat="server">Label</asp:Label>

<asp:Label id="Label1" style="Z-INDEX: 104; LEFT: 99px; POSITION: absolute;
TOP: 64px" runat="server" Width="68px" Height="19px">Form</asp:Label>

<asp:Button id="Button1" style="Z-INDEX: 106; LEFT: 291px; POSITION:
absolute; TOP: 276px" runat="server" Text="Sent" Width="65px"></asp:Button>

</form>

</body>

</HTML>

Server side Script:

Imports System.Web.Mail

Public Class Email_Server

Inherits System.Web.UI.Page

Protected WithEvents txtFrom As System.Web.UI.WebControls.TextBox

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents txtTo As System.Web.UI.WebControls.TextBox

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents txtSubject As System.Web.UI.WebControls.TextBox

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents txtBody As System.Web.UI.WebControls.TextBox

Protected WithEvents Label6 As System.Web.UI.WebControls.Label

Protected WithEvents Label7 As System.Web.UI.WebControls.Label

Protected WithEvents Label8 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

SmtpMail.SmtpServer = "trainee2.com" ' Trainee2.com is my SMTP Name

SmtpMail.Send(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text)

End Sub

End Class

--------------------------------------------------------------------------
Thanks & Regards,
ElanKathir.S.N,
ASM Technologies,
B'lore.
Nov 18 '05 #2

P: n/a
Hi Teemu Keiski,

This is my Code,

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim mailMessage As System.Web.Mail.MailMessage

mailMessage = New System.Web.Mail.MailMessage()

mailMessage.From = "me@contoso.com "

mailMessage.To = "yo*@contoso.com "

mailMessage.Subject = "Test subject"

mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text

mailMessage.Body = "Testing email "

System.Web.Mail.SmtpMail.SmtpServer = "localhost"

Try

System.Web.Mail.SmtpMail.Send(mailMessage)
Response.Write("Message sent!")

Catch ex As Exception

Response.Write(ex.Message)

End Try
End Sub
I add Referce also (Add the cdosys.dll), But i got the One Error
massage:

Could not access 'CDO.Message' object.

Why this Came ?..........

Thanks & Regards

Elankathir,
B'lore,
India.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

P: n/a
ElanKathir .S.N <el*************@yahoo.co.in> wrote in news:OyQGc1F9DHA.1596
@TK2MSFTNGP10.phx.gbl:
Could not access 'CDO.Message' object.

Why this Came ?..........


Do you have CDO installed?

You might also try Indy, its free and has broader support for SMTP than .net
does.

http://www.indyproject.org/

There is an SMTP example at:
http://www.atozed.com/indy/

Indy does not require CDO.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programming is an art form that fights back"
ELKNews - Get your free copy at http://www.atozedsoftware.com

Nov 18 '05 #4

P: n/a
Change
Catch ex As Exception
Response.Write(ex.Message)
To
Catch ex As Exception
Response.Write(ex.InnerException.Message)

That should give you a better clue as to where the problem lies.

"ElanKathir .S.N" <el*************@yahoo.co.in> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
Hi Teemu Keiski,

This is my Code,

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim mailMessage As System.Web.Mail.MailMessage

mailMessage = New System.Web.Mail.MailMessage()

mailMessage.From = "me@contoso.com "

mailMessage.To = "yo*@contoso.com "

mailMessage.Subject = "Test subject"

mailMessage.BodyFormat = System.Web.Mail.MailFormat.Text

mailMessage.Body = "Testing email "

System.Web.Mail.SmtpMail.SmtpServer = "localhost"

Try

System.Web.Mail.SmtpMail.Send(mailMessage)
Response.Write("Message sent!")

Catch ex As Exception

Response.Write(ex.Message)

End Try
End Sub
I add Referce also (Add the cdosys.dll), But i got the One Error
massage:

Could not access 'CDO.Message' object.

Why this Came ?..........

Thanks & Regards

Elankathir,
B'lore,
India.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #5

P: n/a
Hi ElanKathir,

I don't think SMTP virtual server is installed on your IIS.it is part of IIS but you need to install it.
Go to your IIS and look for Default SMTP Virtiual Server.If it is not there install it using the Windows CD.
Here is link which will help you on that.
http://www.microsoft.com/technet/tre...mail_setup.asp
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
"ElanKathir" <sn**********@hotmail.com> wrote in message news:%2****************@tk2msftngp13.phx.gbl...
Hi !

I wrote one code for Send the E-mail, But that code have some problem , So please help me

Here i paste my code and Error:
Error:
Server Error in '/Elan_Sample' Application.
------------------------------------------------------------------------------

The transport failed to connect to the server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server.

Source Error:
Line 36: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Line 37: SmtpMail.SmtpServer = "trainee2.com" ' Trainee2.com is my SMTP Name
Line 38: SmtpMail.Send(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text)
Line 39: End Sub
Line 40: End Class
Source File: C:\Project Files\Root\Elan_Sample\Email Server.aspx.vb Line: 38

Stack Trace:
[COMException (0x80040213): The transport failed to connect to the server.
]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String methodName, Object[] args) +58

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String methodName, Object[] args) +112
System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1840
System.Web.Mail.CdoSysHelper.Send(String from, String to, String subject, String messageText) +74
System.Web.Mail.SmtpMail.Send(String from, String to, String subject, String messageText) +171
Elan_Sample.Email_Server.Button1_Click(Object sender, EventArgs e) in C:\Project Files\Root\Elan_Sample\Email Server.aspx.vb:38
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277



ASP.NET Script :

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Email Server.aspx.vb" Inherits="Elan_Sample.Email_Server"%>
OCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

<HEAD>

<title>Email_Server</title>

<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">

<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">

<meta name="vs_defaultClientScript" content="JavaScript">

<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">

</HEAD>

<body MS_POSITIONING="GridLayout">

<form id="Form1" method="post" runat="server">

<asp:TextBox id="txtFrom" style="Z-INDEX: 100; LEFT: 190px; POSITION: absolute; TOP: 62px" runat="server"></asp:TextBox>

<asp:Label id="Label8" style="Z-INDEX: 113; LEFT: 99px; POSITION: absolute; TOP: 212px" runat="server" Width="68px" Height="19px">Body</asp:Label>

<asp:Label id="Label7" style="Z-INDEX: 112; LEFT: 99px; POSITION: absolute; TOP: 156px" runat="server" Width="68px" Height="19px">Subject</asp:Label>

<asp:Label id="Label6" style="Z-INDEX: 111; LEFT: 99px; POSITION: absolute; TOP: 109px" runat="server" Width="68" Height="19">To</asp:Label>

<asp:TextBox id="txtBody" style="Z-INDEX: 109; LEFT: 192px; POSITION: absolute; TOP: 210px" runat="server"></asp:TextBox>

<asp:Label id="Label4" style="Z-INDEX: 102; LEFT: 126px; POSITION: absolute; TOP: 64px" runat="server">Label</asp:Label>

<asp:TextBox id="txtSubject" style="Z-INDEX: 108; LEFT: 193px; POSITION: absolute; TOP: 157px" runat="server"></asp:TextBox>

<asp:Label id="Label3" style="Z-INDEX: 101; LEFT: 126px; POSITION: absolute; TOP: 64px" runat="server">Label</asp:Label>

<asp:TextBox id="txtTo" style="Z-INDEX: 107; LEFT: 192px; POSITION: absolute; TOP: 106px" runat="server"></asp:TextBox>

<asp:Label id="Label2" style="Z-INDEX: 103; LEFT: 126px; POSITION: absolute; TOP: 64px" runat="server">Label</asp:Label>

<asp:Label id="Label1" style="Z-INDEX: 104; LEFT: 99px; POSITION: absolute; TOP: 64px" runat="server" Width="68px" Height="19px">Form</asp:Label>

<asp:Button id="Button1" style="Z-INDEX: 106; LEFT: 291px; POSITION: absolute; TOP: 276px" runat="server" Text="Sent" Width="65px"></asp:Button>

</form>

</body>

</HTML>

Server side Script:

Imports System.Web.Mail

Public Class Email_Server

Inherits System.Web.UI.Page

Protected WithEvents txtFrom As System.Web.UI.WebControls.TextBox

Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Protected WithEvents Button1 As System.Web.UI.WebControls.Button

Protected WithEvents Label2 As System.Web.UI.WebControls.Label

Protected WithEvents txtTo As System.Web.UI.WebControls.TextBox

Protected WithEvents Label3 As System.Web.UI.WebControls.Label

Protected WithEvents txtSubject As System.Web.UI.WebControls.TextBox

Protected WithEvents Label4 As System.Web.UI.WebControls.Label

Protected WithEvents txtBody As System.Web.UI.WebControls.TextBox

Protected WithEvents Label6 As System.Web.UI.WebControls.Label

Protected WithEvents Label7 As System.Web.UI.WebControls.Label

Protected WithEvents Label8 As System.Web.UI.WebControls.Label

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.

<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

End Sub

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init

'CODEGEN: This method call is required by the Web Form Designer

'Do not modify it using the code editor.

InitializeComponent()

End Sub

#End Region

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Put user code to initialize the page here

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

SmtpMail.SmtpServer = "trainee2.com" ' Trainee2.com is my SMTP Name

SmtpMail.Send(txtFrom.Text, txtTo.Text, txtSubject.Text, txtBody.Text)

End Sub

End Class

--------------------------------------------------------------------------
Thanks & Regards,
ElanKathir.S.N,
ASM Technologies,
B'lore.
Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.