By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,529 Members | 864 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,529 IT Pros & Developers. It's quick & easy.

What is this line of code doing?

!NoItAll
100+
P: 296
Hi:
If someone wouldn't mind helping me out. I have some code from an example from reachmail.net. It was in C# but I've refactored it to vb.net. But, I'm ignorant and although I can follow all of the code (it's very simple code) - I have no idea what one line is doing or why it is there...
It's a little embarassing...
Here's the line
Expand|Select|Wrap|Line Numbers
  1.         System.Net.ServicePointManager.ServerCertificateValidationCallback = Function(s, ce, ca, p) True
  2.  
and here is the context...

Expand|Select|Wrap|Line Numbers
  1. Imports System.Net.Mail
  2.  
  3. Public Class SendViaES
  4.     Public WithEvents client As New System.Net.Mail.SmtpClient()
  5.     Private bSent As Boolean = False
  6.  
  7.     Public Sub easyTest()
  8.         bSent = False
  9.         Dim smtp_host As String = "ssrs.reachmail.net"
  10.         Dim smtp_port As Integer = 25
  11.         Dim user As String = "username"
  12.         Dim pswd As String = "Password"
  13.         Dim rcpt As String = "name@domain.com"
  14.         Dim from As String = "name@domain.com"
  15.         Dim Subject As String = "Brown Fox"
  16.         Dim Body As String = "The quick brown fox jumped over the lazy dogs back."
  17.  
  18.         System.Net.ServicePointManager.ServerCertificateValidationCallback = Function(s, ce, ca, p) True
  19.  
  20.         Dim Mail As New System.Net.Mail.MailMessage(from, rcpt, Subject, Body)
  21.  
  22.         client.Host = smtp_host
  23.         client.Credentials = New System.Net.NetworkCredential(user, pswd)
  24.         client.EnableSsl = True
  25.         client.Port = smtp_port
  26.         Dim userstate As String = "test Message"
  27.         Try
  28.             client.SendAsync(Mail, userstate)
  29.             Do Until bSent = True
  30.                 Application.DoEvents()
  31.             Loop
  32.  
  33.         Catch ex As Exception
  34.             MsgBox(ex.Message, MsgBoxStyle.OkOnly)
  35.         End Try
  36.     End Sub
  37.  
  38.     Public Sub ClientResponse(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles client.SendCompleted
  39.         If e.Cancelled Then
  40.             MsgBox("Server cancelled!")
  41.         Else
  42.             If IsNothing(e.Error) Then
  43.                 MsgBox("Email Sent!")
  44.             Else
  45.                 MsgBox(e.Error.ToString)
  46.             End If
  47.         End If
  48.         bSent = True
  49.     End Sub
  50. End Class
  51.  
Any guidance and explanation would be very much appreciated!

By the way - no, I am not building a spammer app - I am building an SMTP connection inside an application so that a major failure can send an email to engineers responsible for the task the app does.

!NoItAl (the ! says it all)
Feb 5 '16 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.