# IOutbox Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutbox/)

## Register(IOutboxMessageSource) {#register-orleans-durable-messaging-ioutboxmessagesource-11a1d48f}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutbox/methods/register-orleans-durable-messaging-ioutboxmessagesource-11a1d48f/)

```csharp
public abstract IOutbox Register(IOutboxMessageSource source)
```

Registers a source which provides messages sent through [IOutbox](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutbox/).

### Parameters

- `source` (`IOutboxMessageSource`): The source.

### Returns

This outbox.

## Send(MessageId) {#send-orleans-durable-messaging-messageid-00f5628d}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutbox/methods/send-orleans-durable-messaging-messageid-00f5628d/)

```csharp
public abstract void Send(MessageId messageId)
```

Synchronously stages, for the grain's next journal write, a message which a registered [IOutboxMessageSource](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutboxmessagesource/) provides.

### Parameters

- `messageId` (`MessageId`): The message ID, which a registered source provides.

### Exceptions

- `System.ArgumentException`: The ID is unset or too long, or the source's message is invalid or addressed to the sending grain.
- `System.InvalidOperationException`: The ID is pending as an ordinary message, no registered source provides it, the source returned a different ID, or the outbox is unavailable.

## Send(OutboxMessage) {#send-orleans-durable-messaging-outboxmessage-d5b84894}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutbox/methods/send-orleans-durable-messaging-outboxmessage-d5b84894/)

```csharp
public abstract void Send(OutboxMessage message)
```

Synchronously stages an outgoing command for the grain's next journal write.

### Parameters

- `message` (`OutboxMessage`): The fully built outgoing message and required receiver.

### Exceptions

- `System.ArgumentException`: The envelope has an unset identity, invalid subject or destination, or exceeds identity/subject limits.
- `System.InvalidOperationException`: The identity conflicts, an inbox sink backpressured a message addressed to the sending grain, or the outbox is unavailable.

## Withdraw(MessageId) {#withdraw-orleans-durable-messaging-messageid-ef7463a7}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutbox/methods/withdraw-orleans-durable-messaging-messageid-ef7463a7/)

```csharp
public abstract bool Withdraw(MessageId messageId)
```

Synchronously stages, for the grain's next journal write, the removal of a pending message which a registered [IOutboxMessageSource](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutboxmessagesource/) provides.

### Parameters

- `messageId` (`MessageId`): The ID of a message sent through [IOutbox](/orleans/docs/api/csharp/microsoft.orleans.durable/orleans.durable.messaging.ioutbox/).

### Returns

`true` when the outbox staged the removal; `false` when no such message is pending.

### Exceptions

- `System.InvalidOperationException`: The ID is pending as an ordinary message, or the outbox is unavailable.
