Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. [Q] Sending Email using ASP .NET

[Q] Sending Email using ASP .NET

Scheduled Pinned Locked Moved ASP.NET
csharpcomdesignsysadmindata-structures
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tran Quoc Thang
    wrote on last edited by
    #1

    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 beginning Imports 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.

    B 1 Reply Last reply
    0
    • T Tran Quoc Thang

      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 beginning Imports 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.

      B Offline
      B Offline
      Bee Master
      wrote on last edited by
      #2

      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 !!!

      T 1 Reply Last reply
      0
      • B Bee Master

        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 !!!

        T Offline
        T Offline
        Tran Quoc Thang
        wrote on last edited by
        #3

        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 :(

        B 1 Reply Last reply
        0
        • T Tran Quoc Thang

          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 :(

          B Offline
          B Offline
          Bee Master
          wrote on last edited by
          #4

          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 !!!

          T 1 Reply Last reply
          0
          • B Bee Master

            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 !!!

            T Offline
            T Offline
            Tran Quoc Thang
            wrote on last edited by
            #5

            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!

            B 1 Reply Last reply
            0
            • T Tran Quoc Thang

              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!

              B Offline
              B Offline
              Bee Master
              wrote on last edited by
              #6

              :cool: I love .Net too !!! Never comment ur code. If it was hard to write, it should be hard to understand !!!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups