Documentation
¶
Overview ¶
Package gmail provides a client for the Gmail API.
Index ¶
- type Attachment
- type Client
- func (c *Client) DownloadAttachment(ctx context.Context, messageID string, attachmentID string) ([]byte, error)
- func (c *Client) DownloadInlineAttachment(ctx context.Context, messageID string, partID string) ([]byte, error)
- func (c *Client) FetchLabels(ctx context.Context) error
- func (c *Client) GetAttachments(ctx context.Context, messageID string) ([]*Attachment, error)
- func (c *Client) GetLabelID(ctx context.Context, name string) (string, error)
- func (c *Client) GetLabelName(labelID string) string
- func (c *Client) GetLabels() []*gmail.Label
- func (c *Client) GetMessage(ctx context.Context, messageID string, includeBody bool) (*Message, error)
- func (c *Client) GetProfile(ctx context.Context) (*Profile, error)
- func (c *Client) GetThread(ctx context.Context, id string) ([]*Message, error)
- func (c *Client) ModifyMessages(ctx context.Context, ids []string, addLabels, removeLabels []string) error
- func (c *Client) SearchMessageIDs(ctx context.Context, query string, maxResults int64) ([]string, error)
- func (c *Client) SearchMessages(ctx context.Context, query string, maxResults int64) ([]*Message, int, error)
- type LabelResolver
- type Message
- type Profile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Attachment ¶
type Attachment struct {
Filename string `json:"filename"`
MimeType string `json:"mimeType"`
Size int64 `json:"size"`
AttachmentID string `json:"attachmentId,omitempty"`
PartID string `json:"partId"`
IsInline bool `json:"isInline"`
}
Attachment represents metadata about an email attachment
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the Gmail API service
func (*Client) DownloadAttachment ¶
func (c *Client) DownloadAttachment(ctx context.Context, messageID string, attachmentID string) ([]byte, error)
DownloadAttachment downloads a single attachment by message ID and attachment ID
func (*Client) DownloadInlineAttachment ¶
func (c *Client) DownloadInlineAttachment(ctx context.Context, messageID string, partID string) ([]byte, error)
DownloadInlineAttachment downloads an attachment that has inline data
func (*Client) FetchLabels ¶
FetchLabels retrieves and caches all labels from the Gmail account
func (*Client) GetAttachments ¶
GetAttachments retrieves attachment metadata for a message
func (*Client) GetLabelID ¶ added in v1.0.35
GetLabelID resolves a label display name to its ID. Calls FetchLabels if needed.
func (*Client) GetLabelName ¶
GetLabelName resolves a label ID to its display name
func (*Client) GetMessage ¶
func (c *Client) GetMessage(ctx context.Context, messageID string, includeBody bool) (*Message, error)
GetMessage retrieves a single message by ID
func (*Client) GetProfile ¶ added in v1.0.30
GetProfile retrieves the authenticated user's profile
func (*Client) GetThread ¶
GetThread retrieves all messages in a thread. The id parameter can be either a thread ID or a message ID. If a message ID is provided, the thread ID is resolved automatically.
func (*Client) ModifyMessages ¶ added in v1.0.35
func (c *Client) ModifyMessages(ctx context.Context, ids []string, addLabels, removeLabels []string) error
ModifyMessages modifies labels on one or more messages. Uses Messages.Modify for a single message; Messages.BatchModify for multiple. Gmail limits batch operations to 1000 IDs, so this method chunks automatically.
func (*Client) SearchMessageIDs ¶ added in v1.0.35
func (c *Client) SearchMessageIDs(ctx context.Context, query string, maxResults int64) ([]string, error)
SearchMessageIDs returns only message IDs matching the query (no metadata fetch). This is more efficient than SearchMessages when only IDs are needed. Note: returns a single page of results (up to ~100 when maxResults is 0). This matches SearchMessages behavior. For very large result sets, use a more specific query to narrow results.
type LabelResolver ¶
LabelResolver is a function that resolves a label ID to its display name
type Message ¶
type Message struct {
ID string `json:"id"`
ThreadID string `json:"threadId"`
Subject string `json:"subject"`
From string `json:"from"`
To string `json:"to"`
Date string `json:"date"`
Snippet string `json:"snippet"`
Body string `json:"body,omitempty"`
Attachments []*Attachment `json:"attachments,omitempty"`
Labels []string `json:"labels,omitempty"`
Categories []string `json:"categories,omitempty"`
}
Message represents a simplified email message