public static void ConstructAddresses(StructureBuilder builder, Mail_t_Mailbox[] mailboxes, MIME_Encoding_EncodedWord wordEncoder) { builder.StartBracket(); foreach (Mail_t_Mailbox address in mailboxes) { ConstructAddress(builder, address, wordEncoder); } builder.EndBracket(); }
public static void ConstructParts(StructureBuilder builder, MIME_Entity entity, bool includeExtensions) { var wordEncoder = new MIME_Encoding_EncodedWord(MIME_EncodedWordEncoding.B, Encoding.UTF8); wordEncoder.Split = false; if (entity.Body is MIME_b_Multipart) { // Recursive build for multipart builder.StartBracket(); foreach (MIME_Entity child in ((MIME_b_Multipart)entity.Body).BodyParts) { ConstructParts(builder, child, includeExtensions); } if (entity.ContentType != null && entity.ContentType.SubType != null) { builder.SpaceNQuoted(entity.ContentType.SubType.ToUpperInvariant()); } else { builder.AppendQuoted("PLAIN"); } if (includeExtensions) { // conentTypeParameters - Syntax: {("name" SP "value" *(SP "name" SP "value"))} ConstructTypeParameters(builder, entity, wordEncoder); // body disposition Syntax: {(disposition-type [ SP ("name" SP "value" *(SP "name" SP "value"))])} ConstructBodyDisposition(builder, entity, wordEncoder); // body language builder.AppendNil(); // body location builder.AppendNil(); } builder.Append(")"); } else { ConstructSinglePart(builder, entity, wordEncoder, includeExtensions); } }
public static void ConstructAddress(StructureBuilder builder, Mail_t_Mailbox address, MIME_Encoding_EncodedWord wordEncoder) { /* An address structure is a parenthesized list that describes an * electronic mail address. The fields of an address structure * are in the following order: personal name, [SMTP] * at-domain-list (source route), mailbox name, and host name. */ // NOTE: all header fields and parameters must in ENCODED form !!! builder.StartBracket(); // personal name if (address.DisplayName != null) { builder.Append(TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.DisplayName)))); } else { builder.Append("NIL"); } // source route, always NIL (not used nowdays) builder.AppendNil(); // mailbox name builder.Append(" ").Append(TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.LocalPart)))); // host name if (address.Domain != null) { builder.Append(" ").Append(TextUtils.QuoteString(wordEncoder.Encode(RemoveCrlf(address.Domain)))); } else { builder.AppendNil(); } builder.EndBracket(); }