Advertise with us
Control Panel
Forum
Hosting Help
ASP.NET 4.5 & SQL 2012 Hosting
Resources
Notice
Login
Members
Shared Hosting
|
Upgrade
|
Advertise
|
Tutorials
|
Home
»
Questions & Answers
»
Can't send mail using System.Net.Mail
Can't send mail using System.Net.Mail
29 Sep, 11
Author:
popo4
Hello.
I create one asp.net project (in vb) for sending mail using gmail account.
When I test in localhost mail was sent but when I try it placed, here, on aspspider.net I got error message Failure sending mail.
Bellow is code :
Public Sub SendGMail(ByVal txtFromEMailAddress, ByVal txtFromName, ByVal txtPassword, ByVal txtToEmailAddress, ByVal txtSubject, ByVal txtMessage)
Try
Dim msg As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage
msg.From = New System.Net.Mail.MailAddress(txtFromEMailAddress.ToString.Trim, txtFromName.ToString)
msg.To.Add(New System.Net.Mail.MailAddress(txtToEmailAddress))
msg.Subject = txtSubject
msg.IsBodyHtml = True
msg.BodyEncoding = UTF8Encoding.UTF8
msg.Body = txtMessage
Dim fa As System.Net.Mail.MailAddress = New System.Net.Mail.MailAddress(txtFromEMailAddress.ToString.Trim)
Dim sm As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient()
sm.UseDefaultCredentials = False
'Dim gm As System.Net.NetworkCredential = New System.Net.NetworkCredential(fa.ToString, txtPassword.ToString.Trim)
sm.Host = smtp.gmail.com
sm.Port = 587
sm.EnableSsl = True
sm.Timeout = 10000
sm.DeliveryMethod = Net.Mail.SmtpDeliveryMethod.Network
sm.Credentials = New System.Net.NetworkCredential(fa.ToString.Trim, txtPassword.ToString.Trim)
sm.Send(msg)
Catch ex As Exception
MBox(Mail not sent. + vbCrLf + ex.Message.ToString)
End Try
End Sub
Can somebody help me where is error?
Thx to all.
p.s. sorry for my weak english.
Answers .............
Author:
popo4
Posted Date: 02 Oct, 11
no one?
Author:
Nishanth Mohan
Posted Date: 02 Oct, 11
What is the real error message are you getting ? Are you passing the credentials ?
Author:
gabriel martin
Posted Date: 10 Oct, 11
Are You sure that the email account and server exists ??
Author:
popo4
Posted Date: 12 Oct, 11
Error message : Failure sending mail (see my first post - there is code too).
Well, it's a GMail, of course server exist and email account is correct too (username and password).
I try with ports 587 and 465 but... always same error.
Author:
kamal sahib
Posted Date: 27 Oct, 11
Hi popo4 i have the same issue it works on localhost but not in my web site. I did everything! did you find a solution ?
Author:
popo4
Posted Date: 19 Nov, 11
it work on localhost, too... but on web site no.
You must
login
to post answer for this question.
Total
members
:
250798
Average new registrations per day (in last 7 days):
10
New Registration:
Open
Register Now
Talk to Webmaster
Tony John
Facebook
Google+
Twitter
Advertise
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies Pvt Ltd.
All Rights Reserved.