| |
| HCLIENT WINAPI ImapConnect(
|
| |
LPCTSTR lpszHostName, |
|
| |
UINT nRemotePort, |
|
| |
UINT nTimeout, |
|
| |
DWORD dwOptions, |
|
| |
LPSECURITYCREDENTIALS lpCredentials |
|
| );
|
The ImapConnect function is used to establish a
connection with the server. It supports connection options beyond
those provided beyond ImapConnect.
Parameters
- lpszHostName
- A pointer to a null terminated string which specifies the host
name or IP address of the IMAP server.
- nRemotePort
- The port number the client should use to establish the
connection. A value of zero specifies that default port 143 should
be used, which is the standard port number assigned to the IMAP
service. If the secure port number is specified, an implicit
SSL/TLS connection will be established by default.
- nTimeout
- The number of seconds that the client will wait for a response
from the server before failing the current operation.
- dwOptions
- An unsigned integer value which specifies one or more options.
This parameter is constructed by using a bitwise operator with any
of the following values:
| Constant |
Description |
| IMAP_OPTION_NONE |
No connection options specified. A standard connection to the
server will be established using the specified host name and port
number. |
| IMAP_OPTION_IDENTIFY |
This option specifies that the client should identify itself to
the server. If enabled, the client will send the ID command to the
server as defined in RFC 2971. This option has no effect if the
server does not support the ID command. |
| IMAP_OPTION_TUNNEL |
This option specifies that a tunneled TCP connection and/or
port-forwarding is being used to establish the connection to the
server. This changes the behavior of the client with regards to
internal checks of the destination IP address and remote port
number, default feature selection and how the connection is
established. |
| IMAP_OPTION_TRUSTEDSITE |
This option specifies that the server is trusted. The server
certificate will not be validated and the connection will always be
permitted. This option only affects connections using either the
SSL or TLS protocols. |
| IMAP_OPTION_SECURE |
This option specifies that a secure connection should be
established with the server and requires that the server support
either the SSL or TLS protocol. This option is the same as
specifying IMAP_OPTION_SECURE_EXPLICIT, which initiates the secure
session using the STARTTLS command. |
| IMAP_OPTION_SECURE_EXPLICIT |
This option specifies that the client should attempt to
establish a secure connection with the server. Note that the server
must support secure connections using either the SSL or TLS
protocol. |
| IMAP_OPTION_SECURE_IMPLICIT |
This option specifies that the client should attempt to
establish a secure connection with the server. The server must
support secure connections using either the SSL or TLS protocol,
and the secure session must be negotiated immediately after the
connection has been established. |
| IMAP_OPTION_FREETHREAD |
This option specifies that the handle returned by this function
may be used by any thread, and is not limited to the thread which
created it. The application is responsible for ensuring that access
to the handle is synchronized across multiple threads. |
- lpCredentials
- A pointer to a SECURITYCREDENTIALS structure which
is used to establish the client credentials for a secure connection
to the server. The function ImapCreateSecurityCredentials
can be used to create this structure if necessary. If a standard
non-secure connection is being established, or client credentials
are not required by the server, this parameter can be NULL.
Return Value
If the function succeeds, the return value is a handle to a
client session. If the function fails, the return value is
INVALID_CLIENT. To get extended error information, call
ImapGetLastError.
The dwOptions argument can be used to specify the
threading model that is used by the library when a connection is
established. By default, the handle is initially attached to the
thread that created it. From that point on, until the it is
released, only the owner may call functions using that handle. The
ownership of the handle may be transferred from one thread to
another using the ImapAttachThread function.
Specifying the IMAP_OPTION_FREETHREAD option enables any thread
to call any function using the handle, regardless of which thread
created it. It is important to note that this option disables
certain internal safety checks which are performed by the library
and may result in unexpected behavior unless access to the handle
is synchronized. If one thread calls a function in the library, it
must ensure that no other thread will call another function at the
same time using the same handle.
Requirements
Client: Requires Windows 7, Windows Vista or Windows
XP.
Server: Requires Windows Server 2008 or Windows Server
2003.
Header: Include cstools7.h.
Library: Use csmapav7.lib.
Unicode: Implemented as Unicode and ANSI versions.
See Also
ImapAsyncConnect, ImapDisconnect, ImapInitialize, ImapLogin
|
|