E
ElanKathir
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(Object obj, String methodName, Object[] args) +58
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object 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.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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
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(Object obj, String methodName, Object[] args) +58
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object 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.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 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