I want to send email from vb.net 2008. All of my code is correct but i don't know why the message comes "Mail Sending Failure"
here is my code
Imports System.Net.Mail
Public Class frmMailing
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
Sub sendEmail()
Try
SmtpServer.Credentials = New Net.NetworkCredential(Trim("myemail@yahoo.com"), Trim("MyPassword"))
SmtpServer.Port = "995"
SmtpServer.Host = "smtp.mail.yahoo.com"
mail.From = New MailAddress(Trim("myemail@yahoo.com"))
mail.To.Add(Trim("ToEmail@hotmail.com"))
mail.Subject = Trim("Hi")
mail.Body = Trim("Hi")
SmtpServer.Send(mail)
MsgBox("Mail Sent", MsgBoxStyle.Information, "Mail Sent")
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Private Sub frmMailing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sendEmail()
End Sub
End Class
You could check if you can to send email manually trough this SMTP server (enter in command promt "telnet smtp.mail.yahoo.com:995" and after that enter your credentials). You could also check at
how to send email in ASP.NET.
i have change these settings but the error is same. Here is my Code
Imports System.Net.Mail
Public Class frmMailing
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
Sub sendEmail()
Try
SmtpServer.Host = "smtp.mail.yahoo.com"
SmtpServer.Port = "465"
SmtpServer.Credentials = New Net.NetworkCredential(Trim("myemail@yahoo.com"), Trim("MyPassword"))
mail.From = New MailAddress(Trim("myemail@yahoo.com"))
mail.To.Add(Trim("ToEmail@hotmail.com"))
mail.Subject = Trim("Hi")
mail.Body = Trim("Hi")
SmtpServer.Send(mail)
MsgBox("Mail Sent", MsgBoxStyle.Information, "Mail Sent")
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
Private Sub frmMailing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
sendEmail()
End Sub
End Class
NewProgramer
Member
391 Points
232 Posts
Sending Email Failure
Aug 04, 2012 01:07 PM|LINK
Hi
Hope all you are fine.
I want to send email from vb.net 2008. All of my code is correct but i don't know why the message comes "Mail Sending Failure"
here is my code
Imports System.Net.Mail Public Class frmMailing Dim SmtpServer As New SmtpClient() Dim mail As New MailMessage() Sub sendEmail() Try SmtpServer.Credentials = New Net.NetworkCredential(Trim("myemail@yahoo.com"), Trim("MyPassword")) SmtpServer.Port = "995" SmtpServer.Host = "smtp.mail.yahoo.com" mail.From = New MailAddress(Trim("myemail@yahoo.com")) mail.To.Add(Trim("ToEmail@hotmail.com")) mail.Subject = Trim("Hi") mail.Body = Trim("Hi") SmtpServer.Send(mail) MsgBox("Mail Sent", MsgBoxStyle.Information, "Mail Sent") Catch ex As Exception MsgBox(ex.Message.ToString) End Try End Sub Private Sub frmMailing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load sendEmail() End Sub End ClassPlease help me
HostingASPNe...
All-Star
15882 Points
2977 Posts
Re: Sending Email Failure
Aug 04, 2012 04:07 PM|LINK
Hello,
You could check if you can to send email manually trough this SMTP server (enter in command promt "telnet smtp.mail.yahoo.com:995" and after that enter your credentials). You could also check at how to send email in ASP.NET.
Regards
Free ASP.NET Examples and source code.
AccuWebHosti...
Contributor
2212 Points
401 Posts
Re: Sending Email Failure
Aug 05, 2012 02:35 AM|LINK
I think you are using wrong smtp Port.
It should be as follows :
Outgoing mail server (SMTP) settings:
You can also check following URL :
Yahoo Help
Top Windows VPS Provider
NewProgramer
Member
391 Points
232 Posts
Re: Sending Email Failure
Aug 05, 2012 11:52 PM|LINK
i have change these settings but the error is same. Here is my Code
Imports System.Net.Mail Public Class frmMailing Dim SmtpServer As New SmtpClient() Dim mail As New MailMessage() Sub sendEmail() Try SmtpServer.Host = "smtp.mail.yahoo.com" SmtpServer.Port = "465" SmtpServer.Credentials = New Net.NetworkCredential(Trim("myemail@yahoo.com"), Trim("MyPassword")) mail.From = New MailAddress(Trim("myemail@yahoo.com")) mail.To.Add(Trim("ToEmail@hotmail.com")) mail.Subject = Trim("Hi") mail.Body = Trim("Hi") SmtpServer.Send(mail) MsgBox("Mail Sent", MsgBoxStyle.Information, "Mail Sent") Catch ex As Exception MsgBox(ex.Message.ToString) End Try End Sub Private Sub frmMailing_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load sendEmail() End Sub End Classcan you send me your code?
Allen Li - M...
Star
10411 Points
1196 Posts
Re: Sending Email Failure
Aug 06, 2012 05:40 AM|LINK
Hi, please set “EnableSsl” to true:
Additionally, please make sure your “mailSettings” is “web.config” is correct, please refer to the example on the following site:
http://weblogs.asp.net/scottgu/archive/2005/12/10/432854.aspx
If you have any feedback about my replies, please contact msdnmg@microsoft.com
Microsoft One Code Framework