Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Using GMail with ASP.Net: error: The remote certificate is invalid according to the validation procedure.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Carmine [www.thetotalsite.it] - 05 Mar 2008 15:29 GMT
Hi,
I'm trying to use gmail smtp server for an asp.net application, but when I
try to send an email I get this error:

"The remote certificate is invalid according to the validation procedure."

Of course, I have enabled ssl (enableSSL = true) and inserted the network
credentials for my account... but it still doesn't work.

How come does it happen?
How can I solve it?

I am using ASP.Net 2.0 and Google Apps.

Thanks in advance,

Signature

Carmine
Webmaster di www.thetotalsite.it
Blog http://blog.thetotalsite.it

sloan - 05 Mar 2008 15:39 GMT
Go here;
http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!138.entry

get the downloadable code.
(You can download the code HERE. (Right-Click and "Save As" works best)
(<<key phrase to search for)

I have gmail specific code and setup there.

..

There is a 1.1 and 2.0 version.

> Hi,
> I'm trying to use gmail smtp server for an asp.net application, but when I
[quoted text clipped - 11 lines]
>
> Thanks in advance,
Carmine [www.thetotalsite.it] - 05 Mar 2008 16:14 GMT
I tried, but it still doesn't work :-(
As the article explains, I have set the port to 587 or 465, but now I get
this error:

A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond

...Why?

Bye,

Signature

Carmine
Webmaster di www.thetotalsite.it
Blog http://blog.thetotalsite.it

sloan - 05 Mar 2008 18:16 GMT
Firewall or port block?

Something is stopping you.

Can you setup outlook/express to just test it?

>I tried, but it still doesn't work :-(
> As the article explains, I have set the port to 587 or 465, but now I get
[quoted text clipped - 7 lines]
>
> Bye,
Carmine [www.thetotalsite.it] - 05 Mar 2008 18:55 GMT
> Can you setup outlook/express to just test it?

On Windows Mail it works fine.
Moreover, that problem appeared even when I tested the code on my local
machine through visual studio.

Anyhow, incredibly, I edited the code as follows:

Public Shared Function QuickSendEmail(ByVal subject As String, ByVal body As
String, ByVal isHTML As Boolean, ByVal recipient As String) As Boolean
       Dim msg As System.Net.Mail.MailMessage = New
System.Net.Mail.MailMessage()
       msg.To.Add(recipient)
       msg.From = New MailAddress(myemail@mydomain.com, "Staff di The Total
Site .it", System.Text.Encoding.UTF8)
       msg.Subject = subject
       msg.SubjectEncoding = System.Text.Encoding.UTF8
       msg.Body = body
       msg.BodyEncoding = System.Text.Encoding.UTF8
       msg.IsBodyHtml = isHTML
       msg.Priority = MailPriority.Normal

       'Add the Creddentials
       Dim client As SmtpClient = New SmtpClient()
       client.Credentials = New System.Net.NetworkCredential(username,
password)
       client.Port = 587 'or use 465
       client.Host = "smtp.gmail.com"
       client.EnableSsl = True

       client.Send(msg)
       Return True
End Function

And now, it works perfectly :-|
Curious. Before I was using web.config to set up smtp parameters, meh :|

Bye,

Signature

Carmine
Webmaster di www.thetotalsite.it
Blog http://blog.thetotalsite.it


Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.