Secure Property

Specify if a connection to the server is secure.

Syntax

object.Secure [= { True | False } ]

The object is an expression that evaluates to an InternetMail object. The property returns a boolean value.

Remarks

The Secure property determines if a secure connection is established to the server. The default value for this property is False, which specifies that a standard connection to the server is used. To establish a secure connection, the application must set this property value to True prior to calling the Connect method. Once the connection has been established, the client may retrieve messages from the server as with standard connections.

It is strongly recommended that any application that sets this property to True use error handling to trap any errors that may occur. If the control is unable to initialize the security libraries, or otherwise cannot create a secure session for the client, an error will be generated when this property value is set.

Data Type

Boolean

Example

The following example establishes a secure connection to a server and retrieves a message:

  '
  ' Set the Secure property to True, which tells the
  ' component to initialize the security interface and
  ' attempt to establish a secure connection
  '
  On Error Resume Next: Err.Clear
  InternetMail1.Secure = True
  
  If Err.Number Then
      MsgBox "Unable to initialize the security interface"
      Exit Sub
  End If
  
  On Error GoTo 0

  nError = InternetMail1.Connect(strServerName, nServerPort, strUserName, strPassword)
  If nError <> 0 Then
      MsgBox "Unable to connect to server " & strServerName, vbExclamation
      Exit Sub
  End If
  
  If InternetMail1.CertificateStatus <> mailCertificateValid Then
       nResult = MsgBox("The server certificate could not be validated" & vbCrLf & _
                        "Are you sure you wish to continue?", vbYesNo)
  
       If nResult = vbNo Then
            InternetMail1.Disconnect
            Exit Sub
       End If
  End If

  nError = InternetMail1.GetMessage(1)
  If nError <> 0 Then
       InternetMail1.Disconnect
       MsgBox "Unable to retrieve message from server " & strServerName
       Exit Sub
  End If
  
  InternetMail1.Disconnect

See Also

CertificateExpires Property, CertificateIssued Property, CertificateIssuer Property, CertificateStatus Property, CertificateSubject Property, CipherStrength Property, HashStrength Property, SecureCipher Property, SecureHash Property, SecureKeyExchange Property, SecureProtocol Property, Connect Method


Copyright © 2008 Catalyst Development Corporation. All rights reserved.