[Q] Sending Email using ASP .NET
-
Hi everybody, I've writen an application to send email using ASP .NET. But it's not run on my localhost. Please correct me. I wrote this code in the onload event
Dim eml as new EmailMessage eml.from = "tranquocthang2000@yahoo.com" eml.to = "quocthang@vnws.com" eml.subject = "testing" eml.body = "This is a test" SmtpMail.send(eml)
I've also writen this code at the beginningImports System.Web.Mail
When I run this application, an error was occured.Server Error in '/Email' 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 38: Eml.Subject = "Testing email" Line 39: Eml.Body = txtCont.Text Line 40: SmtpMail.Send(Eml) Line 41: End Sub Line 42: End Class Source File: c:\inetpub\wwwroot\Email\default.aspx.vb Line: 40 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.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) +113 System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1846 System.Web.Mail.SmtpMail.Send(MailMessage message) +153 Email.WebForm1.btnSend_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Email\default.aspx.vb:40 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.
-
Hi everybody, I've writen an application to send email using ASP .NET. But it's not run on my localhost. Please correct me. I wrote this code in the onload event
Dim eml as new EmailMessage eml.from = "tranquocthang2000@yahoo.com" eml.to = "quocthang@vnws.com" eml.subject = "testing" eml.body = "This is a test" SmtpMail.send(eml)
I've also writen this code at the beginningImports System.Web.Mail
When I run this application, an error was occured.Server Error in '/Email' 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 38: Eml.Subject = "Testing email" Line 39: Eml.Body = txtCont.Text Line 40: SmtpMail.Send(Eml) Line 41: End Sub Line 42: End Class Source File: c:\inetpub\wwwroot\Email\default.aspx.vb Line: 40 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.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) +113 System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1846 System.Web.Mail.SmtpMail.Send(MailMessage message) +153 Email.WebForm1.btnSend_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\Email\default.aspx.vb:40 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.
Set SmtpMail.SmtpServer to point to localhost before calling SmtpMail.Send method: - SmtpMail.SmtpServer = "localhost" (or point to your smtp provider server) Never comment ur code. If it was hard to write, it should be hard to understand !!!
-
Set SmtpMail.SmtpServer to point to localhost before calling SmtpMail.Send method: - SmtpMail.SmtpServer = "localhost" (or point to your smtp provider server) Never comment ur code. If it was hard to write, it should be hard to understand !!!
Thanks Bee Master so much. It've been done. Thanks! I'm trying to browse in at Webmatrixhosting.net, but it doesn't work, because I don't know Webmatrixhosting's SMTP server name :(
-
Thanks Bee Master so much. It've been done. Thanks! I'm trying to browse in at Webmatrixhosting.net, but it doesn't work, because I don't know Webmatrixhosting's SMTP server name :(
quocthang wrote: I don't know Webmatrixhosting's SMTP server name Webmatrixhosting.net uses authenticated SMTP servers. To send e-mail, you will have to modify the code to acquire access to the servers by using your username & password. You can find help & some sample code for using authenticated SMTP in their support center[^] Cheers Never comment ur code. If it was hard to write, it should be hard to understand !!!
-
quocthang wrote: I don't know Webmatrixhosting's SMTP server name Webmatrixhosting.net uses authenticated SMTP servers. To send e-mail, you will have to modify the code to acquire access to the servers by using your username & password. You can find help & some sample code for using authenticated SMTP in their support center[^] Cheers Never comment ur code. If it was hard to write, it should be hard to understand !!!
hehhe, it's been done. Do you know what server did I use to send email on webmatrixhosting, hehhe "localhost". It's Ok. Thanks every body. I love .NET!
-
hehhe, it's been done. Do you know what server did I use to send email on webmatrixhosting, hehhe "localhost". It's Ok. Thanks every body. I love .NET!
:cool: I love .Net too !!! Never comment ur code. If it was hard to write, it should be hard to understand !!!