473,403 Members | 2,284 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

What is this line of code doing?

!NoItAll
297 100+
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
0 1121

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

Similar topics

18
by: Scott Brady Drummonds | last post by:
Hi, everyeone, I recently stumbled on some code that someone else wrote that I don't like. However, I'm having trouble articulating what the bad quality of the following code is. The...
3
by: Brett | last post by:
What is the following code doing? I see evt and event but what is the difference? <input type="radio" id="us_countryFlag1" name="us_country" onclick="togglePurDec(event)">Yes <script>...
1
by: vishal | last post by:
What does #line 182 parser.y mean in a C program?
4
by: hazz | last post by:
I have inherited code but don't know exactly what this one line of code is doing? What it is the purpose of (ClassFileName)ClassFileName......... > ClassFileName vs2 = (ClassFileName...
6
by: Terry Olsen | last post by:
Dim bytes() As Byte = New Byte(1023) {} If someone could help me understand this line of code (especially the part to the right of the equal sign) I'd be much obliged...
3
by: phonl | last post by:
VB.NET 2005 and ADO2.NET After years of VB6 and ADO coding, I'm checking out ADO2.NET. I spent several hours trying to figure out why the line: objDataAdapter.Update(objDataSet, "myTable") ...
15
by: iwdu15 | last post by:
hi, i have these 2 code snippets: Public Sub ImRec(ByVal IM As IAccIm, ByVal Sender As IAccUser) Dim str As String = IM.GetConvertedText(DECODE) Dim temp As String = str temp =...
14
by: Samant.Trupti | last post by:
Hi all, I have some code that I am unable to understand. Can you please help? int _tmain(int argc, _TCHAR* argv) { // Initialize COM environment. ccLib::CCoInitialize...
33
by: Rocky86 | last post by:
Hello can somebody explain the code to me thx in advance!! <?php $temp=""; $sqlconnect=mysql_connect("localhost","hyperian_track","__munged__"); if(!$sqlconnect) die(mysql_error()); ...
3
by: kimong5145 | last post by:
I keep getting this error warning: unknown escape sequence '\H' for this line strAuthor - " Albert Einstein"; what did I do wrong? I do not know what i am doing wrong.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.