This is a discussion on How to send email in VB.NET 2005(From Windows Applications) within the VB.NET Programming forums, part of the Software Development category; How to send email in from VB.NET(2005) in Windows application. I have tried with the following code. But ...
| |||||||
| Register | FAQ | Members List | Calendar | Mark Forums Read |
| |||
| How to send email in from VB.NET(2005) in Windows application. I have tried with the following code. But i am unable to send. Imports System.Web.Mail Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myMessage As System.Web.Mail.MailMessage Try myMessage = New System.Web.Mail.MailMessage With myMessage .To = "abc@xyz.co.in" .From = "abc@xyz.co.in" .Subject = "Testing Mail " .Body = "This is a testing mail without attachments" .BodyFormat = System.Web.Mail.MailFormat.Html End With System.Web.Mail.SmtpMail.SmtpServer = "smtp.servername.com" System.Web.Mail.SmtpMail.Send(myMessage) Catch myexp As Exception MsgBox(myexp.Message, MsgBoxStyle.Critical, Me.Text) End Try End Sub But it shows the error. "The server rejected one or more recipient addresses. The server response was: 553 sorry, Authentication failed or timed out. Please do get messages first to authenticate yourself.(#4.4.3)". But the above code has successfully executed before 2 months.Now it is not.I don't know where the problem has occured. We are using the smtp server. Please help. |
| Sponsored Links |
| |||
| Hi, Use this code to send mail. Dim myMessage As System.Web.Mail.MailMessage Try myMessage = New System.Web.Mail.MailMessage With myMessage .To = "abc@xyz.co.in" .From = "abc@xyz.co.in" .Subject = "Testing Mail " .Body = "This is a testing mail without attachments" .BodyFormat = System.Web.Mail.MailFormat.Html End With System.Web.Mail.SmtpMail.Send(myMessage) Catch myexp As Exception MsgBox(myexp.Message, MsgBoxStyle.Critical, Me.Text) End Try
__________________ S.Balasubramanian Nothing is impossible |
| |||
| Hi Siva, I think it the problem with the SMTP server Authentication Credential. SO try this part with you code. Create an object for the class SMTPClient, another object for network credential, assign the user name and password of a mail address. map that credential to the SMTP client. It will fix your problem. Code: Public Sub SendMail()
Dim strTo As String = frmMain.txtTo.Text
Dim strFrom As String = frmMain.txtFrom.Text
Dim strSubject As String = frmMain.txtSubject.Text
Dim strBody As String = frmMain.txtBody.Text
Dim mailMessage As New System.Net.Mail.MailMessage(strFrom, strTo,
strSubject, strBody)
Dim mailClient As New
System.Net.Mail.SmtpClient("IpAddressOfMyExchangeServer", 25)
mailClient.Credentials = New
NetworkCredential("IpAddressOfMyExchangeServer\UserName", "Password")
mailClient.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
Try
mailClient.Send(mailMessage)
Catch ex As Exception
frmMain.txtInfo.Text = ex.ToString
Exit Sub
End Try
frmMain.txtInfo.Text = "Your message was sucessfully sent."
End Sub The above code works fine. Hope useful... |
![]() |
| Thread Tools | |
| Display Modes | |
| |
LinkBacks (?)
LinkBack to this Thread: http://www.discussweb.com/vb-net-programming/5308-how-send-email-vb-net-2005-windows-applications.html | |||
| Posted By | For | Type | Date |
| DiscussWeb IT Community - Technical Support and Technology Discussions | This thread | Refback | 02-22-2008 12:37 AM |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to send email in VB.NET 2005(From Windows Applications) | psivakumarmca81 | Discussweb HQ | 2 | 02-22-2008 07:33 PM |
| Practical issues when we develop code in Windows Forms in C#.Net 2005 | Sathish Kumar | C# Programming | 10 | 09-20-2007 06:17 AM |
| Email Send Using MYSQL or Oracle | sivaramakrishnan | Database Support | 1 | 08-08-2007 02:39 AM |
| How to convert a SMS message in to Email in Windows mobile? | theone | Mobile Software Development | 1 | 07-24-2007 10:41 PM |
| How to Send Email from a PHP Script Using SMTP Authentication? | Sabari | PHP Programming | 1 | 07-20-2007 04:42 AM |