S
samarthkumar84
Hi
I had used following code for sending e-mail but facing this problem.
I want to send this e-mail in ASP.NET using VB.NET code. I am
attaching both code an output.
CODE
Imports System.Web.HttpCookie
Imports System.Web.Mail
Imports System.Web.Mail.SmtpMail
Imports System.Web.HttpCookieCollection
Imports System.IO
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
#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
Dim mycookie As New HttpCookie("canada bank", "Your
transaction is completed successfully.")
'mycookie.Expires = System.Convert.ToDateTime(2)
Response.Cookies.Add(mycookie)
Dim msg As New MailMessage()
Dim strwriter As New StringWriter()
Dim txt As New HtmlTextWriter(strwriter)
txt.RenderBeginTag("head")
txt.RenderBeginTag("title")
txt.Write("thank you!")
txt.RenderEndTag()
txt.RenderBeginTag("body")
txt.WriteLine("thank you for transaction through canda bank!")
txt.RenderEndTag()
txt.RenderEndTag()
msg.From = "canada bank.com"
msg.To = TextBox1.Text
msg.Subject = "thank you for registering"
msg.Body = strwriter.ToString
msg.BodyFormat = MailFormat.Html
SmtpMail.Send(msg)
End Sub
End Class
OUTPUT
Server Error in '/WebApplication15' Application.
--------------------------------------------------------------------------------
The "SendUsing" configuration value is invalid.
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
"SendUsing" configuration value is invalid.
Source Error:
Line 48: msg.Body = strwriter.ToString
Line 49: msg.BodyFormat = MailFormat.Html
Line 50: SmtpMail.Send(msg)
Line 51: End Sub
Line 52: End Class
Source File: C:\Inetpub\wwwroot\WebApplication15\WebForm1.aspx.vb
Line: 50
Stack Trace:
[COMException (0x80040220): The "SendUsing" configuration value is
invalid.
]
[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.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args) +29
System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
System.Web.Mail.CdoSysHelper.Send(MailMessage message)
System.Web.Mail.SmtpMail.Send(MailMessage message)
WebApplication15.WebForm1.Button1_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication15\WebForm1.aspx.vb:50
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()
I had used following code for sending e-mail but facing this problem.
I want to send this e-mail in ASP.NET using VB.NET code. I am
attaching both code an output.
CODE
Imports System.Web.HttpCookie
Imports System.Web.Mail
Imports System.Web.Mail.SmtpMail
Imports System.Web.HttpCookieCollection
Imports System.IO
Public Class WebForm1
Inherits System.Web.UI.Page
Protected WithEvents TextBox1 As System.Web.UI.WebControls.TextBox
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
#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
Dim mycookie As New HttpCookie("canada bank", "Your
transaction is completed successfully.")
'mycookie.Expires = System.Convert.ToDateTime(2)
Response.Cookies.Add(mycookie)
Dim msg As New MailMessage()
Dim strwriter As New StringWriter()
Dim txt As New HtmlTextWriter(strwriter)
txt.RenderBeginTag("head")
txt.RenderBeginTag("title")
txt.Write("thank you!")
txt.RenderEndTag()
txt.RenderBeginTag("body")
txt.WriteLine("thank you for transaction through canda bank!")
txt.RenderEndTag()
txt.RenderEndTag()
msg.From = "canada bank.com"
msg.To = TextBox1.Text
msg.Subject = "thank you for registering"
msg.Body = strwriter.ToString
msg.BodyFormat = MailFormat.Html
SmtpMail.Send(msg)
End Sub
End Class
OUTPUT
Server Error in '/WebApplication15' Application.
--------------------------------------------------------------------------------
The "SendUsing" configuration value is invalid.
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
"SendUsing" configuration value is invalid.
Source Error:
Line 48: msg.Body = strwriter.ToString
Line 49: msg.BodyFormat = MailFormat.Html
Line 50: SmtpMail.Send(msg)
Line 51: End Sub
Line 52: End Class
Source File: C:\Inetpub\wwwroot\WebApplication15\WebForm1.aspx.vb
Line: 50
Stack Trace:
[COMException (0x80040220): The "SendUsing" configuration value is
invalid.
]
[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.Type.InvokeMember(String name, BindingFlags invokeAttr,
Binder binder, Object target, Object[] args) +29
System.Web.Mail.LateBoundAccessHelper.CallMethod(Type type, Object
obj, String methodName, Object[] args)
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
[HttpException (0x80004005): Could not access 'CDO.Message' object.]
System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String
methodName, Object[] args)
System.Web.Mail.CdoSysHelper.Send(MailMessage message)
System.Web.Mail.SmtpMail.Send(MailMessage message)
WebApplication15.WebForm1.Button1_Click(Object sender, EventArgs e)
in C:\Inetpub\wwwroot\WebApplication15\WebForm1.aspx.vb:50
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain()