Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 53. GoogleMail
GoogleMail component Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Available as of Camel 2.15
Component Description Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The Google Mail component provides access to Gmail via the Google Mail Web APIs.
Google Mail uses the OAuth 2.0 protocol for authenticating a Google account and authorizing access to user data. Before you can use this component, you will need to create an account and generate OAuth credentials. Credentials comprise of a clientId, clientSecret, and a refreshToken. A handy resource for generating a long-lived refreshToken is the OAuth playground.
Maven users will need to add the following dependency to their pom.xml for this component:
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-google-mail</artifactId> <version>2.15-SNAPSHOT</version> </dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-google-mail</artifactId>
<version>2.15-SNAPSHOT</version>
</dependency>
URI Format Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The GoogleMail Component uses the following URI format:
google-mail://endpoint-prefix/endpoint?[options]
google-mail://endpoint-prefix/endpoint?[options]
Endpoint prefix can be one of:
- attachments
- drafts
- history
- labels
- messages
- threads
- users
GoogleMailComponent Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The GoogleMail Component can be configured with the options below. These options can be provided using the component's bean property
configuration
of type org.apache.camel.component.google.mail.GoogleMailConfiguration
.
Option | Type | |
---|---|---|
accessToken | String | OAuth 2 access token. This typically expires after an hour so refreshToken is recommended for long term usage. |
applicationName | String | Google drive application name. Example would be "camel-google-mail/1.0" |
clientId | String | Client ID of the drive application |
clientSecret | String | Client secret of the drive application |
refreshToken |
String
|
OAuth 2 refresh token. Using this, the Google Mail component can obtain a new accessToken whenever the current one expires - a necessity if the application is long-lived. |
scopes | List<String> | Specifies the level of permissions you want a drive application to have to a user account. See https://developers.google.com/gmail/api/auth/scopes for more info. |
Producer Endpoints Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Producer endpoints can use endpoint prefixes followed by endpoint names and associated options described next. A shorthand alias can be used for some endpoints. The endpoint URI MUST contain a prefix.
Endpoint options that are not mandatory are denoted by []. When there are no mandatory options for an endpoint, one of the set of [] options MUST be provided. Producer endpoints can also use a special option
inBody
that in turn should contain the name of the endpoint option whose value will be contained in the Camel Exchange In message.
Any of the endpoint options can be provided in either the endpoint URI, or dynamically in a message header. The message header name must be of the format
CamelGoogleMail.<option>
. Note that the inBody
option overrides message header, i.e. the endpoint option inBody=option
would override a CamelGoogleMail.option
header.
For more information on the endpoints and options see API documentation at: https://developers.google.com/gmail/api/v1/reference/
1. Endpoint Prefix attachments Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following endpoints can be invoked with the prefix
attachments
as follows:
google-mail://attachments/endpoint?[options]
google-mail://attachments/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
get | id, messageId, userId | com.google.api.services.gmail.model.MessagePartBody |
URI Options for attachments Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Name | Type |
---|---|
id | String |
messageId | String |
userId | String |
2. Endpoint Prefix drafts Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following endpoints can be invoked with the prefix
drafts
as follows:
google-mail://drafts/endpoint?[options]
google-mail://drafts/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
create | [mediaContent], content, userId |
com.google.api.services.gmail.model.Draft
|
|
delete | id, userId | ||
get | id, userId |
com.google.api.services.gmail.model.Draft
|
|
list | userId |
com.google.api.services.gmail.model.ListDraftsResponse
|
|
send | [mediaContent], content, userId |
com.google.api.services.gmail.model.Message
|
|
update | [mediaContent], content, id, userId |
com.google.api.services.gmail.model.Draft
|
URI Options for drafts Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Name | Type |
---|---|
content | com.google.api.services.gmail.model.Draft |
id | String |
mediaContent | com.google.api.client.http.AbstractInputStreamContent |
userId | String |
3. Endpoint Prefix history Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following endpoints can be invoked with the prefix
history
as follows:
google-mail://history/endpoint?[options]
google-mail://history/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
list | userId |
com.google.api.services.gmail.model.ListHistoryResponse
|
URI Options for history Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Name | Type |
---|---|
userId | String |
4. Endpoint Prefix labels Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following endpoints can be invoked with the prefix
labels
as follows:
google-mail://labels/endpoint?[options]
google-mail://labels/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
create | content, userId |
com.google.api.services.gmail.model.Label
|
|
delete | id, userId | ||
get | id, userId |
com.google.api.services.gmail.model.Label
|
|
list | userId |
com.google.api.services.gmail.model.ListLabelsResponse
|
|
patch | content, id, userId |
com.google.api.services.gmail.model.Label
|
|
update | content, id, userId |
com.google.api.services.gmail.model.Label
|
URI Options for labels Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Name | Type |
---|---|
content | com.google.api.services.gmail.model.Label |
id | String |
userId | String |
5. Endpoint Prefix messages Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following endpoints can be invoked with the prefix
messages
as follows:
google-mail://messages/endpoint?[options]
google-mail://messages/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
delete | id, userId | ||
get | id, userId |
com.google.api.services.gmail.model.Message
|
|
gmailImport | [mediaContent], content, userId |
com.google.api.services.gmail.model.Message
|
|
insert | [mediaContent], content, userId |
com.google.api.services.gmail.model.Message
|
|
list | userId |
com.google.api.services.gmail.model.ListMessagesResponse
|
|
modify | id, modifyMessageRequest, userId |
com.google.api.services.gmail.model.Message
|
|
send | [mediaContent], content, userId |
com.google.api.services.gmail.model.Message
|
|
trash | id, userId |
|
|
untrash | id, userId |
|
URI Options for messages Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Name | Type |
---|---|
content | com.google.api.services.gmail.model.Message |
id | String |
mediaContent | com.google.api.client.http.AbstractInputStreamContent |
modifyMessageRequest | com.google.api.services.gmail.model.ModifyMessageRequest |
userId | String |
6. Endpoint Prefix threads Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following endpoints can be invoked with the prefix
threads
as follows:
google-mail://threads/endpoint?[options]
google-mail://threads/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
delete | id, userId | ||
get | id, userId |
com.google.api.services.gmail.model.Thread
|
|
list | userId |
com.google.api.services.gmail.model.ListThreadsResponse
|
|
modify | content, id, userId |
com.google.api.services.gmail.model.Thread
|
|
trash | id, userId | ||
untrash | id, userId |
URI Options for threads Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Name | Type |
---|---|
content | com.google.api.services.gmail.model.ModifyThreadRequest |
id | String |
userId | String |
7. Endpoint Prefix users Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
The following endpoints can be invoked with the prefix
users
as follows:
google-mail://users/endpoint?[options]
google-mail://users/endpoint?[options]
Endpoint | Shorthand Alias | Options | Result Body Type |
---|---|---|---|
getProfile | userId | com.google.api.services.gmail.model.Profile |
URI Options for users Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Name | Type |
---|---|
userId | String |
Consumer Endpoints Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Any of the producer endpoints can be used as a consumer endpoint. Consumer endpoints can use Scheduled Poll Consumer Options with a
consumer.
prefix to schedule endpoint invocation. Consumer endpoints that return an array or collection will generate one exchange per element, and their routes will be executed once for each exchange.
Message Headers Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
Any URI option can be provided in a message header for producer endpoints with a
CamelGoogleMail.
prefix.
Message Body Link kopierenLink in die Zwischenablage kopiert!
Link kopierenLink in die Zwischenablage kopiert!
All result message bodies utilize objects provided by the underlying APIs used by the GoogleMailComponent. Producer endpoints can specify the option name for incoming message body in the
inBody
endpoint URI parameter. For endpoints that return an array or collection, a consumer endpoint will map every element to distinct messages.