Send email using smtp but operation timed out using ZOHO - vb.net

Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential(abc#zoho.com,abc123)
Smtp_Server.Port = 465
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.zoho.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress(abc#zoho.com)
e_mail.To.Add("david#hotmail.com")
e_mail.Subject = "Testing"
e_mail.IsBodyHtml = False
Smtp_Server.Send(e_mail)
Return True
Now I trying to send email to other person but the error show me the operation timed out, when using ZOHO to send. And I got find the solution but still fail to send. How can I solve it?

Try to use PORT : 587
Smtp_Server.Port = 587

Related

can't send Email from Webservice written in vb.net

I wanna send an Email from my Webservice, written in vb.net, but I get an Timeout.
What is wrong?
Dim toaddress As MailAddress = New MailAddress("xxx")
Dim fromaddress As MailAddress = New MailAddress("yyy")
' The structure for MailMessage(from, to)
Dim message As MailMessage = New MailMessage(fromaddress, toaddress)
message.Subject = "I have sent you a message from a program!"
message.Body = "Hello World!"
Dim messanger As SmtpClient = New SmtpClient("smtpxxx", 995)
messanger.Credentials = New NetworkCredential("user", "password")
messanger.EnableSsl = True
messanger.Send(message)
You are doing many things wrong and some of the information you have given are not clear enough. host name and port names have to give properly. it chooses which mail service you are using, from your code it is not correctly provided, so i will give a snippet that uses gmail to send mail. please go through this and make changes as per your SmtpHost.
Try
Dim Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials = False
Smtp_Server.Credentials = New Net.NetworkCredential("email", "password")
Smtp_Server.Port = 587
Smtp_Server.EnableSsl = True
Smtp_Server.Host = "smtp.gmail.com"
e_mail = New MailMessage()
e_mail.From = New MailAddress(txtemail.Text)
e_mail.To.Add(txtemail.Text)
e_mail.Subject = "Email Sending"
e_mail.IsBodyHtml = False
e_mail.Body = txtMessage.Text
Smtp_Server.Send(e_mail)
MsgBox("Mail Sent")
Catch error_t As Exception
MsgBox(error_t.ToString)
End Try
This link help you to find the smtp.Server and Port numbers, you can use this thread for check the limitations of smtp.servers

How to send mail with asp.net in vb.net

When I send an email
By pressing the button
No error will not be
Dim mm As MailMessage = New MailMessage("ashkanramedani1370#gmail.com", "ashkanramedani1370#gmail.com", "HELLO", "test")
Dim smtp As New SmtpClient("gmail.com")
smtp.EnableSsl = True
Dim NetworkCred As NetworkCredential = New System.Net.NetworkCredential()
NetworkCred.UserName = "ashkanramedani1370#gmail.com"
NetworkCred.Password = "123456789#"
smtp.UseDefaultCredentials = False
smtp.Credentials = NetworkCred
smtp.Port = 587
Try
smtp.Send(mm)
Catch ex As Exception
'----
End Try
But did not receive the email
Please help me
gmail.com is not an SMTP server.
You want smtp.gmail.com.

getting error when i am sending mail via smtp

Dim MESSAGE As New MailMessage()
MESSAGE.From = New MailAddress(Mail_From)
MESSAGE.BodyEncoding = System.Text.Encoding.UTF8
MESSAGE.To.Add(email)
MESSAGE.Subject = "Testing"
MESSAGE.BodyEncoding = System.Text.Encoding.UTF8
MESSAGE.Body = msg
Dim smtp As New SmtpClient()
smtp.Host = SMTP_Host
smtp.Port = SMTP_Port
smtp.UseDefaultCredentials = False
smtp.Credentials = New System.Net.NetworkCredential(Mail_User, Mail_PW)
smtp.EnableSsl = False
smtp.Send(MESSAGE)
i got error:
MAIL Error Message:Mailbox unavailable. The server response was:
This email has identified as high probability of being a spam mail
by our
The mail has been rejected by the server, there is nothing you can do to resolve this. You could in theory attempt to modify the content so that is does not appear as spammy, but this is likely to be a long and tedious process.

Email not send using Gmail smtp on host

I've used this code to sending emails. When I test this code in LOCALHOST, it works correctly, but in host, I get this error:
Failure sending mail.few
My code is:
Dim MailMsg As New MailMessage(New Net.Mail.MailAddress("MYUSERNAME#gmail.com"), New Net.Mail.MailAddress("myname#gmail.com"))
MailMsg.Subject = "test"
MailMsg.Body = "test"
MailMsg.IsBodyHtml = True
Dim SmtpMail As New Net.Mail.SmtpClient
Dim SMTPUserInfo As New Net.NetworkCredential()
SMTPUserInfo.UserName = "MYUSERNAME"
SMTPUserInfo.Password = "MYPASSWORD"
SmtpMail.UseDefaultCredentials = False
SmtpMail.Credentials = SMTPUserInfo
SmtpMail.Host = "smtp.gmail.com"
SmtpMail.Port = 587
SmtpMail.EnableSsl = True
SmtpMail.Send(MailMsg)
'Start by creating a mail message object
Dim MyMailMessage As New MailMessage()
'From requires an instance of the MailAddress type
MyMailMessage.From = New MailAddress("USERNAME#gmail.com")
'To is a collection of types
MyMailMessage.To.Add("DESTINATION#EXAMPLE.COM")
MyMailMessage.Subject = "XXXXXXX" & x
MyMailMessage.Body = "XXXXXXXXXXXXXXXXXXX "
Dim attach As New Attachment(fileName)
MyMailMessage.Attachments.Add(attach)
'Create the SMTPClient object and specify the SMTP GMail server
Dim SMTPServer As New SmtpClient("smtp.gmail.com")
SMTPServer.Port = 587
SMTPServer.Credentials = New System.Net.NetworkCredential("USERNAME#gmail.com", "PASSWD")
SMTPServer.EnableSsl = True
SMTPServer.Send(MyMailMessage)
SMTPServer.Dispose()
MyMailMessage.Dispose()

unable to send email from VB.net

This is my code to send email using GMAIL and VB.NET:
Try
Dim SmtpServer As New SmtpClient()
SmtpServer.Credentials = New Net.NetworkCredential("mygmailid#gmail.com", "mypassword")
SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"
SmtpServer.EnableSsl = True
mail = New MailMessage()
mail.From = New MailAddress("mygmailid#gmail.com", "Asked for help", System.Text.Encoding.UTF8)
Mail.To.Add("sendtoemail#id")
Mail.Subject = "A help query has been raised"
mail.Body = frm_dashboard.user_data_fetch.Item(1, 0).Value.ToString + " " + ask_for_help.txt_message_ask_help.Text
SmtpServer.Send(Mail)
MessageBox.Show("Mail sent")
Catch ex As Exception
MsgBox(ex.ToString())
MessageBox.Show("Oops something went wrong.")
End Try
But this shows me this error:-
This is the order I have it in, you might want to try this:
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.Credentials = New System.Net.NetworkCredential("gmailID", "password")
SMTP.EnableSsl = True
SMTP.Port = "587"
SMTP.Send(Mail)
Also note that I don't actually use the "#gmail.com" when passing in my credentials.