MimeMessageReferences Property

Get the list of references to other messages.

Definition

Namespace: MimeKit
Assembly: MimeKit.Core (in MimeKit.Core.dll) Version: 5.0.0
C#
public MessageIdList References { get; }

Property Value

MessageIdList
The references.

Implements

IMimeMessageReferences

Remarks

The References header contains a chain of Message-Ids back to the original message that started the thread.

Example

C#
                    public static MimeMessage CreateReply (MimeMessage message)
{
    var reply = new MimeMessage ();

    var subject = message.Subject ?? string.Empty;

    reply.From.Add (new MailboxAddress ("Chandler Bing", "chandler@friends.com"));
    reply.To.AddRange (message.ReplyTo.Count > 0 ? message.ReplyTo : message.From);
    reply.Subject = subject.StartsWith ("Re:", StringComparison.OrdinalIgnoreCase) ? subject : "Re: " + subject;

    // Message-Id values do not include the angle brackets. MimeKit adds them when
    // the headers are serialized.
    reply.MessageId = MimeUtils.GenerateMessageId ();

    // Thread the reply by setting the In-Reply-To and References headers.
    if (!string.IsNullOrEmpty (message.MessageId)) {
        reply.InReplyTo = message.MessageId;

        // The References header contains the list of message-ids in the thread
        // starting with the original message.
        foreach (var id in message.References)
            reply.References.Add (id);

        reply.References.Add (message.MessageId);
    }

    reply.Body = new TextPart ("plain") {
        Text = "Could I *be* any more excited?"
    };

    return reply;
}
                  

See Also