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. error on sending mail

error on sending mail

Scheduled Pinned Locked Moved ASP.NET
helpcsharphtmlcomsysadmin
5 Posts 4 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.
  • A Offline
    A Offline
    Any_India
    wrote on last edited by
    #1

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0 ' System.Net.Mail.SmtpClient is the alternate class for this in 2.0 Dim smtpClient As New SmtpClient() Dim message As New MailMessage() Try Dim fromAddress As New MailAddress(txtEmail.Text, txtName.Text) ' You can specify the host name or ipaddress of your server ' Default in IIS will be localhost smtpClient.Host = "localhost" 'Default port will be 25 smtpClient.Port = 25 'From address will be given as a MailAddress Object message.From = fromAddress ' To address collection of MailAddress message.[To].Add("anup2005debnath@gmail.com") message.Subject = "Feedback" ' CC and BCC optional ' MailAddressCollection class is used to send the email to various users ' You can specify Address as new MailAddress("admin1@yoursite.com") message.CC.Add("anup2005debnath@gmail.com") message.CC.Add("anup2005debnath@gmail.com") ' You can specify Address directly as string message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) 'Body can be Html or text format 'Specify true if it is html message message.IsBodyHtml = False ' Message body content message.Body = txtMessage.Text ' Send SMTP mail smtpClient.Send(message) lblStatus.Text = "Email successfully sent." Catch ex As Exception lblStatus.Text = "Send Email Failed." & ex.Message End Try i got error "failed to send message" plz solve the problem

    I A P 3 Replies Last reply
    0
    • A Any_India

      Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0 ' System.Net.Mail.SmtpClient is the alternate class for this in 2.0 Dim smtpClient As New SmtpClient() Dim message As New MailMessage() Try Dim fromAddress As New MailAddress(txtEmail.Text, txtName.Text) ' You can specify the host name or ipaddress of your server ' Default in IIS will be localhost smtpClient.Host = "localhost" 'Default port will be 25 smtpClient.Port = 25 'From address will be given as a MailAddress Object message.From = fromAddress ' To address collection of MailAddress message.[To].Add("anup2005debnath@gmail.com") message.Subject = "Feedback" ' CC and BCC optional ' MailAddressCollection class is used to send the email to various users ' You can specify Address as new MailAddress("admin1@yoursite.com") message.CC.Add("anup2005debnath@gmail.com") message.CC.Add("anup2005debnath@gmail.com") ' You can specify Address directly as string message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) 'Body can be Html or text format 'Specify true if it is html message message.IsBodyHtml = False ' Message body content message.Body = txtMessage.Text ' Send SMTP mail smtpClient.Send(message) lblStatus.Text = "Email successfully sent." Catch ex As Exception lblStatus.Text = "Send Email Failed." & ex.Message End Try i got error "failed to send message" plz solve the problem

      I Offline
      I Offline
      I am BATMAN
      wrote on last edited by
      #2

      you don't have to specify message.isbodyHTML if you want to set it false (that's default) But for failing to send the message...Do you have IIS and SMTP setup correctly on your local machine that's running this?

      A 1 Reply Last reply
      0
      • A Any_India

        Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0 ' System.Net.Mail.SmtpClient is the alternate class for this in 2.0 Dim smtpClient As New SmtpClient() Dim message As New MailMessage() Try Dim fromAddress As New MailAddress(txtEmail.Text, txtName.Text) ' You can specify the host name or ipaddress of your server ' Default in IIS will be localhost smtpClient.Host = "localhost" 'Default port will be 25 smtpClient.Port = 25 'From address will be given as a MailAddress Object message.From = fromAddress ' To address collection of MailAddress message.[To].Add("anup2005debnath@gmail.com") message.Subject = "Feedback" ' CC and BCC optional ' MailAddressCollection class is used to send the email to various users ' You can specify Address as new MailAddress("admin1@yoursite.com") message.CC.Add("anup2005debnath@gmail.com") message.CC.Add("anup2005debnath@gmail.com") ' You can specify Address directly as string message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) 'Body can be Html or text format 'Specify true if it is html message message.IsBodyHtml = False ' Message body content message.Body = txtMessage.Text ' Send SMTP mail smtpClient.Send(message) lblStatus.Text = "Email successfully sent." Catch ex As Exception lblStatus.Text = "Send Email Failed." & ex.Message End Try i got error "failed to send message" plz solve the problem

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #3

        Any_India wrote:

        smtpClient.Host = "localhost" 'Default port will be 25 smtpClient.Port = 25

        Does your SMTP Server configured Properly ?

        cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net

        1 Reply Last reply
        0
        • I I am BATMAN

          you don't have to specify message.isbodyHTML if you want to set it false (that's default) But for failing to send the message...Do you have IIS and SMTP setup correctly on your local machine that's running this?

          A Offline
          A Offline
          Any_India
          wrote on last edited by
          #4

          is there any way to set up iis and smtp server than plz tel me. Actualy i m new in this topic

          1 Reply Last reply
          0
          • A Any_India

            Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click ' System.Web.Mail.SmtpMail.SmtpServer is obsolete in 2.0 ' System.Net.Mail.SmtpClient is the alternate class for this in 2.0 Dim smtpClient As New SmtpClient() Dim message As New MailMessage() Try Dim fromAddress As New MailAddress(txtEmail.Text, txtName.Text) ' You can specify the host name or ipaddress of your server ' Default in IIS will be localhost smtpClient.Host = "localhost" 'Default port will be 25 smtpClient.Port = 25 'From address will be given as a MailAddress Object message.From = fromAddress ' To address collection of MailAddress message.[To].Add("anup2005debnath@gmail.com") message.Subject = "Feedback" ' CC and BCC optional ' MailAddressCollection class is used to send the email to various users ' You can specify Address as new MailAddress("admin1@yoursite.com") message.CC.Add("anup2005debnath@gmail.com") message.CC.Add("anup2005debnath@gmail.com") ' You can specify Address directly as string message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) message.Bcc.Add(New MailAddress("anup2005debnath@gmail.com")) 'Body can be Html or text format 'Specify true if it is html message message.IsBodyHtml = False ' Message body content message.Body = txtMessage.Text ' Send SMTP mail smtpClient.Send(message) lblStatus.Text = "Email successfully sent." Catch ex As Exception lblStatus.Text = "Send Email Failed." & ex.Message End Try i got error "failed to send message" plz solve the problem

            P Offline
            P Offline
            Perry Holman
            wrote on last edited by
            #5

            Pls. see my answer before. http://www.codeproject.com/Messages/3011416/Re-How-to-send-Mail-through-SMTP.aspx[^]

            Welcome to www.softwaretree.net! This website is generated completely by static html pages transforming technology. You can find many excellent audio/video tools there!

            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