Problem in Senting E-Mail using the SmtpMail

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
 
T

Teemu Keiski

Hi,

SMTP FAQ
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=268037

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist


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
 
E

ElanKathir .S.N

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 = "(e-mail address removed) "

mailMessage.To = "(e-mail address removed) "

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.
 
C

Chad Z. Hower aka Kudzu

ElanKathir .S.N said:
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
 
J

Jim Hughes

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.
 
M

Marshal Antony

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/tr...rver2003/proddocs/standard/qss_mail_setup.asp
Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com


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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top