Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Send mail with gmail

Author  Topic 

hima
Starting Member

7 Posts

Posted - 2008-08-14 : 06:04:58
I got an error like "The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required. Learn more at " when i send a html formatted email. my code is


-------------------------------------------------


Try
dim Mail as string=""
Dim logo As New Net.Mail.LinkedResource(imageurl)

logo.ContentId = "Logo"
logo.TransferEncoding = System.Net.Mime.TransferEncoding.Base64

Mail = Mail & "<b>Welcome to our site.com!!</b>"
Mail = Mail & "<BR><img src=\"cid:Logo\" >""

Dim alternateView1 As Net.Mail.AlternateView = Net.Mail.AlternateView.CreateAlternateViewFromString(Mail, System.Text.Encoding.UTF8, MediaTypeNames.Text.Html)
alternateView1.LinkedResources.Add(logo)

Dim Mailmessage As New System.Net.Mail.MailMessage
Dim SmtpServer As New Net.Mail.SmtpClient()
SmtpServer.Credentials = New System.Net.NetworkCredential("mail@gmail.com", "password")

SmtpServer.Port = 587
SmtpServer.Host = "smtp.gmail.com"

Mailmessage.From = New System.Net.Mail.MailAddress("mail@gmail.com", "mail Team", System.Text.Encoding.UTF8)
Mailmessage.Subject = subject

Mailmessage.IsBodyHtml = True
Mailmessage.BodyEncoding = System.Text.Encoding.UTF8
Mailmessage.SubjectEncoding = System.Text.Encoding.UTF8

Mailmessage.AlternateViews.Add(alternateView1)



Mailmessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure

Mailmessage.To.Add("mail@gmail.com") 'to user


SmtpServer.UseDefaultCredentials = False
SmtpServer.DeliveryMethod = SmtpDeliveryMethod.Network
SmtpServer.EnableSsl = True



SmtpServer.Send(Mailmessage)

Return True



Catch ex As Exception

Throw
' Return ex.Message.ToString & errormsg

End Try
------------


pls respond this problem.......
thanks

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-10-24 : 05:05:33
From my experience. I dont think you can send an email in .net pretending its from gmail, Which obviously is not your domain.

This would be classified as SPAM. But if you are the account holder, then you have to enter the correct password of the gmail account for it to work. Else, you will have to use your domain to send this email ie A VALID EMAIL ADDRESS AND PASSWORD
Go to Top of Page
   

- Advertisement -