Cloud Mail 2020 C++ Builder Edition

Questions / Feedback?

GMail Component

Properties   Methods   Events   Configuration Settings   Errors  

The GMail component provides an easy way to manage sending and receiving mail in Gmail.

Syntax

TicmGMail

Remarks

This component provides an easy to use interface for Gmail using version 3 of the Gmail REST API. To use the component, first set the Authorization property to a valid OAuth token. The GMail component can be used for sending or creating new messages; retrieving existing messages; creating, deleting, or sending drafts; and several other functionalities supported by the Gmail API.

This component requires authentication via OAuth 2.0. First, perform OAuth authentication using the OAuth component or a separate process. Once complete you should have an authorization string which looks like:

Bearer ya29.AHES6ZSZEJzATdZYjeihDn5W-VrXSsxEZu5p0pclxGdKKQ

Assign this value to the Authorization property before attempting any operations. For Example:

Oauth oauth = new Oauth();
 
oauth.ClientId = "3c65828c-6376-4286-91b5-2381c3904a97"; 
oauth.ClientSecret = "mkk2a2M-B5TQI7o5p_N0fR-CHYVn7e3yH~";
oauth.AuthorizationScope = "https://www.googleapis.com/auth/gmail.readonly";
oauth.ServerTokenURL = "https://accounts.google.com/o/oauth2/token";
oauth.ServerAuthURL = "https://accounts.google.com/o/oauth2/auth";
oauth.GrantType = OauthGrantTypes.ogtAuthorizationCode;
 
gmail.Authorization = oauth.GetAuthorization();
Consult the documentation for the service for more information about supported scope values and more details on OAuth authentication.

Sending Messages

There are two methods for sending messages using the Gmail component. The SendMail method will send a message directly. Alternatively, you can create a message draft and then send an existing draft using the SendDraft method. In both cases the properties of the new message are assigned through the Message properties (MessageSubject, MessageBodyContent, MessageCc, etc.).

Sending a Message with SendDraft:

gmail.MessageSubject = "I am sending an email.";
gmail.MessageBodyContentType = "TEXT";
gmail.MessageBodyContent = "Just wanted to let you know.";
gmail.MessageTo = "reader@tautology.org";

gmail.CreateDraft();
string messageId = gmail.MessageInfo[0].Id;

gmail.SendDraft(messageId);

Receiving Messages

Information about messages fetched by the component can be accessed through the MessageInfo* properties. The MessageInfo* properties is populated when the ListMessages, FetchMessageInfo, or Search methods are called.

The ListMessages method will list the messages.

By default, the component will fetch one page of 100 messages when ListMessages is called. If additional messages remain in the folder, the NextPageToken property will be populated. If ListMessages is then called again on the same folder the next page of messages will be fetched. The example below populates the MessageInfo* properties with all the messages in the mailbox.

do {
  gmail.ListMessages("", "");
} while (gmail.NextPageToken.Length > 0);

The message page size may also be changed by using the MessagePageSize configuration setting.

Property List


The following is the full list of the properties of the component with short descriptions. Click on the links for further details.

AttachmentProvides the raw attachment content.
AuthorizationAn OAuth Authorization String.
AutoDecodePartsDetermines whether to automatically decode message parts.
FirewallAutoDetectThis property tells the component whether or not to automatically detect and use firewall system settings, if available.
FirewallTypeThis property determines the type of firewall to connect through.
FirewallHostThis property contains the name or IP address of firewall (optional).
FirewallPasswordThis property contains a password if authentication is to be used when connecting through the firewall.
FirewallPortThis property contains the TCP port for the firewall Host .
FirewallUserThis property contains a user name if authentication is to be used connecting through a firewall.
MessageProvides the raw message content.
MessageAttachmentsA semicolon separated list of files to attach to a message.
MessageBccA comma separated list of recipients for blind carbon copies for a message.
MessageBodyContentThe body content for a message.
MessageBodyContentTypeThe body content type for a message.
MessageCcA comma separated list of recipients for carbon copies for a message.
MessageCountThe total number of messages on the mailbox.
MessageFromThe author of a message.
MessageHeaderCountThe number of records in the MessageHeader arrays.
MessageHeaderFieldThe property of a message header in a message info listing.
MessageHeaderValueThe value of a message header in a message info listing.
MessageIndexThe index of the MessageInfo that should be used to populate the MessageHeaders and MessageParts collections.
MessageInfoCountThe number of records in the MessageInfo arrays.
MessageInfoBccThe blind carbon copy recipient of a message in a message info listing.
MessageInfoCcThe carbon copy recipient of a message in a message info listing.
MessageInfoFromThe sender of a message in a message info listing.
MessageInfoHistoryIdThe history identifier of a message in a message info listing.
MessageInfoIdThe unique identifier of a message in a message info listing.
MessageInfoInternalDateThe internal date of a message in a message info listing.
MessageInfoLabelsMessage labels in a message info listing.
MessageInfoSizeThe size of a message in a message info listing.
MessageInfoSnippetThe snippet of a message in a message info listing.
MessageInfoSubjectThe subject of a message in a message info listing.
MessageInfoThreadIdThe thread ID of a message in a message info listing.
MessageInfoToThe recipients of a message in a message info listing.
MessagePartCountThe number of records in the MessagePart arrays.
MessagePartAttachmentIdThe attachment ID of a message part in a message info listing.
MessagePartContentTypeThe content type of a message part in a message info listing.
MessagePartDataThe data of a message part in a message info listing.
MessagePartFilenameThe filename of a message part in a message info listing.
MessagePartIdThe unique identifier of a message part in a message info listing.
MessagePartSizeThe size of a message part in a message info listing.
MessageSubjectThe subject of a message.
MessageToA comma separated list of recipients for a message.
NextPageTokenThe token to retrieve the next page with data.
ProxyAuthSchemeThis property is used to tell the component which type of authorization to perform when connecting to the proxy.
ProxyAutoDetectThis property tells the component whether or not to automatically detect and use proxy system settings, if available.
ProxyPasswordThis property contains a password if authentication is to be used for the proxy.
ProxyPortThis property contains the TCP port for the proxy Server (default 80).
ProxyServerIf a proxy Server is given, then the HTTP request is sent to the proxy instead of the server otherwise specified.
ProxySSLThis property determines when to use SSL for the connection to the proxy.
ProxyUserThis property contains a user name, if authentication is to be used for the proxy.
SSLAcceptServerCertEncodedThe certificate (PEM/base64 encoded).
SSLCertEncodedThe certificate (PEM/base64 encoded).
SSLCertStoreThe name of the certificate store for the client certificate.
SSLCertStorePasswordIf the certificate store is of a type that requires a password, this property is used to specify that password in order to open the certificate store.
SSLCertStoreTypeThe type of certificate store for this certificate.
SSLCertSubjectThe subject of the certificate used for client authentication.
SSLServerCertEncodedThe certificate (PEM/base64 encoded).

Method List


The following is the full list of the methods of the component with short descriptions. Click on the links for further details.

AddMessageLabelsAdds the specified labels to the message specified by MessageId.
AppendToMailboxImports a message into only this user's mailbox, with standard email delivery scanning and classification similar to receiving via SMTP. Does not send a message.
ConfigSets or retrieves a configuration setting.
CountMessagesGet the total number of messages in the mailbox.
CreateDraftCreates a new email draft.
DeleteDeletes a message.
DeleteDraftDeletes a draft permanently.
DeletePermanentlyDeletes the specified messages permanently.
FetchAttachmentRetrieves a raw attachment.
FetchMessageRetrieves a message including the message parts.
FetchMessageHeadersRetrieves the headers of a message.
FetchMessageInfoRetrieves a message info.
FetchMessageRawRetrieves the raw message of the specified message ID.
ListDraftsLists the drafts in a mailbox.
ListMessagesLists the messages in a mailbox.
RemoveMessageLabelsRemoves the specified labels from the message specified by MessageId.
ResetReset the component.
RestoreRestores a message.
SearchSearch for messages.
SendCustomRequestSend a custom HTTP request.
SendDraftSends an existing Draft.
SendMailSends a new email.

Event List


The following is the full list of the events fired by the component with short descriptions. Click on the links for further details.

ErrorInformation about errors during data delivery.
LogFires once for each log message.
MessageHeaderFired when a header is retrieved from the server.
MessageInfoFired when a message is retrieved from the server.
MessagePartFired when a message part is retrieved from the server.
SSLServerAuthenticationFired after the server presents its certificate to the client.
SSLStatusShows the progress of the secure connection.
TransferFired while a document transfers (delivers document).

Configuration Settings


The following is a list of configuration settings for the component with short descriptions. Click on the links for further details.

IncludeSpamTrashWhether or not to include the Spam and Trash folders during the message listing.
MessagePageSizePage size for fetching messages.
MIMEMessageMIME encoded message to send.
ResolveLabelNamesWhether or not to resolve the label names to show the display name instead of the id.
ResponseTypeThe level of information to retrieve for a specific email.
XPathProvides a way to point to a specific element in the returned XML or JSON response.
XTextThe text of the current element.
AcceptEncodingUsed to tell the server which types of content encodings the client supports.
AllowHTTPCompressionThis property enables HTTP compression for receiving data.
AllowHTTPFallbackWhether HTTP/2 connections are permitted to fallback to HTTP/1.1.
AppendWhether to append data to LocalFile.
AuthorizationThe Authorization string to be sent to the server.
BytesTransferredContains the number of bytes transferred in the response data.
ChunkSizeSpecifies the chunk size in bytes when using chunked encoding.
CompressHTTPRequestSet to true to compress the body of a PUT or POST request.
EncodeURLIf set to true the URL will be encoded by the component.
FollowRedirectsDetermines what happens when the server issues a redirect.
GetOn302RedirectIf set to true the component will perform a GET on the new location.
HTTP2HeadersWithoutIndexingHTTP2 headers that should not update the dynamic header table with incremental indexing.
HTTPVersionThe version of HTTP used by the component.
IfModifiedSinceA date determining the maximum age of the desired document.
KeepAliveDetermines whether the HTTP connection is closed after completion of the request.
KerberosSPNThe Service Principal Name for the Kerberos Domain Controller.
LogLevelThe level of detail that is logged.
MaxRedirectAttemptsLimits the number of redirects that are followed in a request.
NegotiatedHTTPVersionThe negotiated HTTP version.
OtherHeadersOther headers as determined by the user (optional).
ProxyAuthorizationThe authorization string to be sent to the proxy server.
ProxyAuthSchemeThe authorization scheme to be used for the proxy.
ProxyPasswordA password if authentication is to be used for the proxy.
ProxyPortPort for the proxy server (default 80).
ProxyServerName or IP address of a proxy server (optional).
ProxyUserA user name if authentication is to be used for the proxy.
SentHeadersThe full set of headers as sent by the client.
StatusLineThe first line of the last response from the server.
TransferredDataThe contents of the last response from the server.
TransferredDataLimitThe maximum number of incoming bytes to be stored by the component.
TransferredHeadersThe full set of headers as received from the server.
TransferredRequestThe full request as sent by the client.
UseChunkedEncodingEnables or Disables HTTP chunked encoding for transfers.
UseIDNsWhether to encode hostnames to internationalized domain names.
UserAgentInformation about the user agent (browser).
ConnectionTimeoutSets a separate timeout value for establishing a connection.
FirewallAutoDetectTells the component whether or not to automatically detect and use firewall system settings, if available.
FirewallHostName or IP address of firewall (optional).
FirewallPasswordPassword to be used if authentication is to be used when connecting through the firewall.
FirewallPortThe TCP port for the FirewallHost;.
FirewallTypeDetermines the type of firewall to connect through.
FirewallUserA user name if authentication is to be used connecting through a firewall.
KeepAliveIntervalThe retry interval, in milliseconds, to be used when a TCP keep-alive packet is sent and no response is received.
KeepAliveTimeThe inactivity time in milliseconds before a TCP keep-alive packet is sent.
LingerWhen set to True, connections are terminated gracefully.
LingerTimeTime in seconds to have the connection linger.
LocalHostThe name of the local host through which connections are initiated or accepted.
LocalPortThe port in the local host where the component binds.
MaxLineLengthThe maximum amount of data to accumulate when no EOL is found.
MaxTransferRateThe transfer rate limit in bytes per second.
ProxyExceptionsListA semicolon separated list of hosts and IPs to bypass when using a proxy.
TCPKeepAliveDetermines whether or not the keep alive socket option is enabled.
TcpNoDelayWhether or not to delay when sending packets.
UseIPv6Whether to use IPv6.
LogSSLPacketsControls whether SSL packets are logged when using the internal security API.
OpenSSLCADirThe path to a directory containing CA certificates.
OpenSSLCAFileName of the file containing the list of CA's trusted by your application.
OpenSSLCipherListA string that controls the ciphers to be used by SSL.
OpenSSLPrngSeedDataThe data to seed the pseudo random number generator (PRNG).
ReuseSSLSessionDetermines if the SSL session is reused.
SSLCACertsA newline separated list of CA certificate to use during SSL client authentication.
SSLCheckCRLWhether to check the Certificate Revocation List for the server certificate.
SSLCipherStrengthThe minimum cipher strength used for bulk encryption.
SSLEnabledCipherSuitesThe cipher suite to be used in an SSL negotiation.
SSLEnabledProtocolsUsed to enable/disable the supported security protocols.
SSLEnableRenegotiationWhether the renegotiation_info SSL extension is supported.
SSLIncludeCertChainWhether the entire certificate chain is included in the SSLServerAuthentication event.
SSLNegotiatedCipherReturns the negotiated ciphersuite.
SSLNegotiatedCipherStrengthReturns the negotiated ciphersuite strength.
SSLNegotiatedCipherSuiteReturns the negotiated ciphersuite.
SSLNegotiatedKeyExchangeReturns the negotiated key exchange algorithm.
SSLNegotiatedKeyExchangeStrengthReturns the negotiated key exchange algorithm strength.
SSLNegotiatedVersionReturns the negotiated protocol version.
SSLProviderThe name of the security provider to use.
SSLSecurityFlagsFlags that control certificate verification.
SSLServerCACertsA newline separated list of CA certificate to use during SSL server certificate validation.
TLS12SignatureAlgorithmsDefines the allowed TLS 1.2 signature algorithms when UseInternalSecurityAPI is True.
TLS12SupportedGroupsThe supported groups for ECC.
TLS13KeyShareGroupsThe groups for which to pregenerate key shares.
TLS13SignatureAlgorithmsThe allowed certificate signature algorithms.
TLS13SupportedGroupsThe supported groups for (EC)DHE key exchange.
AbsoluteTimeoutDetermines whether timeouts are inactivity timeouts or absolute timeouts.
FirewallDataUsed to send extra data to the firewall.
InBufferSizeThe size in bytes of the incoming queue of the socket.
OutBufferSizeThe size in bytes of the outgoing queue of the socket.

Copyright (c) 2022 /n software inc. - All rights reserved.
Cloud Mail 2020 C++ Builder Edition - Version 20.0 [Build 8308]