پرش به مستندات
C#

client.Subscriptions

هر متد در این فضای نام: امضا، پارامترها، آنچه برمی‌گرداند و یک نمونه.

متدها

The newsletters and mailing lists the mailbox receives: list them by sender or by domain, unsubscribe, and move what they send.

Subscriptions.ListAsync

List subscriptions

محدوده‌های دسترسیthreads:read
امضای متد
Task<JsonObject> ListAsync(    string? status = null,    string? q = null,    string? sort = null,    int? limit = null,    int? offset = null,    string? address = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Returns the newsletters and mailing lists the mailbox receives, as the Subscriptions page of the app shows them: one row per sender and the address it writes to, found from the List-Unsubscribe header of the mail it sends. Each row says how much mail the sender sent, how much of it is unread and how much arrived in the last 30 days, how it lets you unsubscribe, and the rule that keeps moving its new mail when there is one.

status: is active, the default, or unsubscribed. q: searches the sender, and sort: is recent, most, unread or name. Paging is by offset:: total counts every match and hasMore says whether another page follows.

A key limited to particular addresses lists only the subscriptions delivered to them, and address: narrows the list to one address.

پارامترها

statusstring?

active or unsubscribed. Defaults to active.

qstring?

Searches the sender name and address.

sortstring?

recent, most, unread or name, also in OpenEmail\Constants\SubscriptionSorts. Defaults to recent.

limitint?

Rows per page, 1 to 200, defaulting to 50.

offsetint?

How many rows to skip.

addressstring?

Only the subscriptions delivered to this address.

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A JsonObject, not a Page, with object set to ListAsync, data, total, counts and hasMore, where counts holds how many are active and unsubscribed.

نمونه

using OpenEmail.Constants; var subscriptions = await client.Subscriptions.ListAsync(sort: SubscriptionSorts.Most, limit: 20); foreach (var row in subscriptions["data"]?.AsArray() ?? []){    Console.WriteLine($"{row?["senderEmail"]} {row?["total"]} messages, {row?["unread"]} unread, {row?["method"]}");} Console.WriteLine($"{subscriptions["counts"]?["unsubscribed"]} already unsubscribed");

نکته‌ها

  • Read only, so the SDK retries it after a network failure like any other read.

همچنین در دسترس در

API
GET /subscriptions
TypeScript
subscriptions.list()
Python
subscriptions.list()
Ruby
subscriptions.list
PHP
subscriptions->list
Go
Subscriptions.List
Java
subscriptions().list
CLI
openemail subscriptions list

Subscriptions.ListDomainsAsync

List subscriptions by domain

محدوده‌های دسترسیthreads:read
امضای متد
Task<JsonObject> ListDomainsAsync(    string? status = null,    string? q = null,    string? sort = null,    int? limit = null,    int? offset = null,    string? address = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Returns the same subscriptions as Subscriptions.ListAsync, one row per sender domain with the counts of its senders added up, so a company that writes from several addresses is one row. unsubscribable counts the senders on the domain that can be unsubscribed without a person opening a page, which is what Subscriptions.UnsubscribeDomainAsync acts on.

It takes the same filters as Subscriptions.ListAsync.

پارامترها

statusstring?

active or unsubscribed. Defaults to active.

qstring?

Searches the sender name and address.

sortstring?

recent, most, unread or name. Defaults to recent.

limitint?

Rows per page, 1 to 200, defaulting to 50.

offsetint?

How many rows to skip.

addressstring?

Only the subscriptions delivered to this address.

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A JsonObject, not a Page, with object set to ListAsync, data, total, counts and hasMore.

نمونه

var domains = await client.Subscriptions.ListDomainsAsync(sort: "most"); foreach (var row in domains["data"]?.AsArray() ?? []){    Console.WriteLine($"{row?["domain"]}: {row?["senders"]} senders, {row?["unsubscribable"]} can be unsubscribed here");}

نکته‌ها

  • Read only, so the SDK retries it after a network failure like any other read.

همچنین در دسترس در

API
GET /subscriptions/domains
TypeScript
subscriptions.listDomains()
Python
subscriptions.list_domains()
Ruby
subscriptions.list_domains
PHP
subscriptions->listDomains
Go
Subscriptions.ListDomains
Java
subscriptions().listDomains
CLI
openemail subscriptions list-domains

Subscriptions.UnsubscribeAsync

Unsubscribe from a sender

محدوده‌های دسترسیthreads:write
امضای متد
Task<JsonObject> UnsubscribeAsync(    string id,    IReadOnlyDictionary<string, object?>? body = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Unsubscribes the way the sender asks for it: a one-click request to its unsubscribe address when it offers one, otherwise an unsubscribe email sent from the address the mail arrived at. A sender that only offers a page cannot be unsubscribed by a program, so method is link and url is the page a person has to open. bin set to true also moves every conversation from the sender to the Bin.

A sender that gives no way to unsubscribe is a 422 unsubscribe_unsupported, and one whose one-click request failed with no address to write to is a 502 unsubscribe_refused. A subscription delivered to an address the key does not reach is a 404.

پارامترها

idstringالزامی

The subscription, from Subscriptions.ListAsync.

binbool

Also move every conversation from the sender to the Bin. Defaults to false.

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A JsonObject with object set to unsubscribe, subscriptionId, method, url and binned.

نمونه

var result = await client.Subscriptions.UnsubscribeAsync("sub_7d2c1f0a9b3e4c5d6e7f8a9b", body: new Body { ["bin"] = true }); if ((string?)result["method"] == "link"){    Console.WriteLine($"Open {result["url"]} to finish unsubscribing");}else{    Console.WriteLine($"Unsubscribed by {result["method"]}, {result["binned"]} conversations binned");}

نکته‌ها

  • The SDK does not retry it, because a second call can send a second unsubscribe email.

همچنین در دسترس در

API
POST /subscriptions/{id}/unsubscribe
TypeScript
subscriptions.unsubscribe()
Python
subscriptions.unsubscribe()
Ruby
subscriptions.unsubscribe
PHP
subscriptions->unsubscribe
Go
Subscriptions.Unsubscribe
Java
subscriptions().unsubscribe
CLI
openemail subscriptions unsubscribe

Subscriptions.UnsubscribeDomainAsync

Unsubscribe from a whole domain

محدوده‌های دسترسیthreads:write
امضای متد
Task<JsonObject> UnsubscribeDomainAsync(    string domain,    IReadOnlyDictionary<string, object?>? body = null,    string? apiKey = null,    CancellationToken cancellationToken = default)

Unsubscribes from every sender on a domain that can be unsubscribed without a person opening a page, with a one-click request or an unsubscribe email, as the domain view of the Subscriptions page does. unsubscribed counts the senders it worked for, skipped the senders that only offer a page and failed the ones that did not accept it.

bin set to true also moves their conversations to the Bin, and address keeps it to the subscriptions delivered to one address. A key limited to particular addresses acts only on the subscriptions delivered to them.

پارامترها

domainstringالزامی

The sender domain, from Subscriptions.ListDomainsAsync.

binbool

Also move the conversations to the Bin. Defaults to false.

addressstring

Only the subscriptions delivered to this address.

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A JsonObject with object set to domain_unsubscribe, domain, unsubscribed, skipped, failed and binned.

نمونه

var result = await client.Subscriptions.UnsubscribeDomainAsync("news.acme.com", body: new Body { ["address"] = "[email protected]" }); Console.WriteLine($"{result["unsubscribed"]} unsubscribed, {result["skipped"]} need a person, {result["failed"]} failed");

نکته‌ها

  • The SDK does not retry it, because a second call can send unsubscribe emails again.

همچنین در دسترس در

API
POST /subscriptions/domains/{domain}/unsubscribe
TypeScript
subscriptions.unsubscribeDomain()
Python
subscriptions.unsubscribe_domain()
Ruby
subscriptions.unsubscribe_domain
PHP
subscriptions->unsubscribeDomain
Go
Subscriptions.UnsubscribeDomain
Java
subscriptions().unsubscribeDomain
CLI
openemail subscriptions unsubscribe-domain

Subscriptions.MoveAsync

Move what a sender sent

محدوده‌های دسترسیthreads:write
امضای متد
Task<JsonObject> MoveAsync(    string id,    IReadOnlyDictionary<string, object?> body,    string? apiKey = null,    CancellationToken cancellationToken = default)

Moves every conversation from the sender to the archive, the Bin or a label, as the Subscriptions page does. destination is archive, bin or label, and label needs labelId, or the call is a 422 label_not_found.

With future, the default, a rule keeps doing it to new mail from the sender to that address, which also needs rules:write. ruleName names that rule. ["future"] = false drops a rule made that way before, when the key holds rules:write.

پارامترها

idstringالزامی

The subscription, from Subscriptions.ListAsync.

destinationdictionaryالزامی

archive, bin or label, also in OpenEmail\Constants\SubscriptionDestinations.

labelIdstring

The label to file under, for label.

futurebool

Keep doing it to new mail with a rule. Defaults to true.

ruleNamestring

A name for that rule.

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A JsonObject with object set to subscription_move, subscriptionId, moved and ruleId.

نمونه

using OpenEmail.Constants; var result = await client.Subscriptions.MoveAsync("sub_7d2c1f0a9b3e4c5d6e7f8a9b", new Body{    ["destination"] = SubscriptionDestinations.Label,    ["labelId"] = "newsletters",    ["ruleName"] = "File Acme news",}); Console.WriteLine($"{result["moved"]} conversations moved, rule {result["ruleId"]?.ToString() ?? "none"}");

نکته‌ها

  • The SDK retries it after a network failure, which is safe because moving the same mail again changes nothing and the rule is updated rather than added twice.

همچنین در دسترس در

API
POST /subscriptions/{id}/move
TypeScript
subscriptions.move()
Python
subscriptions.move()
Ruby
subscriptions.move
PHP
subscriptions->move
Go
Subscriptions.Move
Java
subscriptions().move
CLI
openemail subscriptions move