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