client.OutOfOffice
Jede Methode in diesem Namespace: ihre Signatur, ihre Parameter, was sie zurückgibt und ein Beispiel.
Methoden
The automatic reply an address sends while its owner is away: read the replies saved in the workspace, set one for an address or a catch-all with its dates, subject and message, and remove it.
OutOfOffice.ListAsync
Read out of office replies
Task<IReadOnlyList<JsonObject>> ListAsync( string? address = null, string? apiKey = null, CancellationToken cancellationToken = default)Returns every out of office reply saved in the workspace, by address. With address: the list holds exactly one row, the reply of that address, which reads enabled: false with empty text when none was ever saved.
active says whether the reply is going out right now: it is on, the start has passed and the end has not. An address is one address, such as [email protected], or *@example.com for the catch-all of a domain.
Parameter
addressstring?One address, such as
[email protected], or*@example.comfor the catch-all of a domain. Left out, every reply saved in the workspace.cancellationTokenCancellationTokenCancels the request.
apiKeystring?Overrides the client's API key for this call only.
Rückgabe
A list of JsonObject items, each { object: 'out_of_office', address, enabled, active, startsAt, endsAt, subject, message, contactsOnly, updatedAt }. startsAt and updatedAt are null on an address that never saved a reply, and a null endsAt keeps the reply on until it is switched off.
Beispiel
var replies = await client.OutOfOffice.ListAsync(); foreach (var reply in replies){ Console.WriteLine($"{reply["address"]}: {((bool?)reply["active"] == true ? "replying now" : "not replying")}");}Hinweise
A key or an app limited to particular addresses or domains lists only the replies of the addresses it holds, and of a catch-all only when it holds the domain whole. Naming an address it does not hold is a 422
capability_unsupported.A whole domain, written
@example.com, is a 422invalid_parameteronaddress, because a reply is set on one address or on a catch-all.Read only, so the SDK retries it after a network failure like any other read.
Auch verfügbar über
OutOfOffice.SetAsync
Set an out of office reply
Task<JsonObject> SetAsync( string address, IReadOnlyDictionary<string, object?> body, string? apiKey = null, CancellationToken cancellationToken = default)Saves the out of office reply of one address, or of a catch-all with *@example.com, replacing whatever was saved. While it is active, each person who writes to the address gets the message once for the whole away period, as a reply in the same thread. Mail that would not alert anyone gets no reply: spam, mail a rule filed away, newsletters and other bulk mail, automatic mail, bounces, blocked senders and the workspace's own addresses. With contactsOnly, only people in the contacts, or people the workspace has written to, are answered.
Leave startsAt out to start now, and endsAt out or null to keep it on until it is switched off. Both take a DateTimeOffset or an ISO 8601 string with an offset. An address with a reply of its own is never answered by the catch-all. Replies count toward the monthly sends, carry no tracking, and still go out on muted threads.
Parameter
addressstringErforderlichOne address, such as
[email protected], or*@example.comfor the catch-all of a domain. A key or an app limited to particular addresses or domains reaches only the addresses it holds, and a catch-all only when it holds the domain whole.messagestringErforderlichThe reply, as plain text, 1 to 10,000 characters once trimmed. Line breaks are kept.
subjectstringThe subject of the reply, at most 255 characters. Left out or empty, the reply answers with
Re:and the subject received.enabledboolWhether the reply is switched on. Left out, true.
falsekeeps the text and pauses the reply.startsAtDateTimeOffset or stringWhen the reply starts. Left out or null, now.
endsAtDateTimeOffset or stringWhen it stops, later than
startsAt. Left out or null, it stays on until it is switched off.contactsOnlyboolAnswer only contacts and people the workspace has written to. Left out, false.
cancellationTokenCancellationTokenCancels the request.
apiKeystring?Overrides the client's API key for this call only.
Rückgabe
A JsonObject, the reply read back as it is stored: { object: 'out_of_office', address, enabled, active, startsAt, endsAt, subject, message, contactsOnly, updatedAt }, with active saying whether mail arriving now is answered.
Beispiel
var reply = await client.OutOfOffice.SetAsync("[email protected]", new Body{ ["subject"] = "Away until Monday", ["message"] = "I am away until Monday and will answer then. For anything urgent, write to [email protected].", ["startsAt"] = DateTimeOffset.UtcNow, ["endsAt"] = DateTimeOffset.UtcNow.AddDays(5), ["contactsOnly"] = true,}); Console.WriteLine($"{reply["address"]} answers until {reply["endsAt"]}");Hinweise
It replaces the whole reply, so a field left out goes back to its default instead of keeping what was saved. Send the full reply each time.
An address that is not in the workspace or names a whole domain, an empty message, and an
endsAtthat is not afterstartsAtor is already in the past are each a 422invalid_parameter. A key or an app that does not hold the address gets a 422capability_unsupported.The SDK retries this call after a network failure, which is safe because saving the same reply twice leaves the same reply.
Auch verfügbar über
OutOfOffice.ClearAsync
Remove an out of office reply
Task<JsonObject> ClearAsync( string address, string? apiKey = null, CancellationToken cancellationToken = default)Removes the saved reply of one address or catch-all, so nothing is answered from it any more. Removing a reply that was never saved changes nothing, which is why the SDK retries this call.
To pause a reply and keep its text, save it with ["enabled"] = false through SetAsync instead.
Parameter
addressstringErforderlichOne address, such as
[email protected], or*@example.comfor the catch-all of a domain. A key or an app limited to particular addresses or domains reaches only the addresses it holds, and a catch-all only when it holds the domain whole.cancellationTokenCancellationTokenCancels the request.
apiKeystring?Overrides the client's API key for this call only.
Rückgabe
A JsonObject, { object: 'out_of_office', address, deleted: true }.
Beispiel
var cleared = await client.OutOfOffice.ClearAsync("[email protected]"); Console.WriteLine($"{cleared["address"]} no longer answers by itself");Hinweise
A whole domain, written
@example.com, is a 422invalid_parameteronaddress. A key or an app that does not hold the address gets a 422capability_unsupported.Removing the reply of a catch-all leaves the replies of single addresses on that domain as they are.