Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I use Vb.net (2005 and 2013).
I use this code sending emails:
VB
Dim SmtpServer As New SmtpClient()
            Dim mail As New MailMessage()
            SmtpServer.Credentials = New _
		Net.NetworkCredential("username@gmail.com", "password")
            SmtpServer.Port = 587
            SmtpServer.Host = "smtp.gmail.com"
            mail = New MailMessage()
            mail.From = New MailAddress("YOURusername@gmail.com")
            mail.To.Add("TOADDRESS")
            mail.Subject = "Test Mail"
            mail.Body = "This is for testing SMTP mail from GMAIL"
            SmtpServer.Send(mail)


and it works fine but only if credential password has got no special characters like '@','!',...

What I have tried:

I have tried with some smtp servers like gmail, register, ecc.
I have tried both with .net 2.0 and .net 4.5.1

Thank a lot!
Posted
Updated 26-Jan-18 5:09am
Comments
Richard MacCutchan 26-Jan-18 7:04am    
What happens when the password contains special characters?

1 solution

Try to pass the password enclosed by double quotes (which must be each preceeded by another double quote to tell VB that it is not the end of the string):
VB
Net.NetworkCredential("username@gmail.com", """password""")
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900