import type {AddressType} from "../enums.js" import {MessageFormat} from "../enums.js" import {Address} from "./address.js" import {PropertyTags} from "../property_tags.js" import type {TopLevelProperties} from "../streams/top_level_properties.js" import {OneOffEntryId} from "./one_off_entry_id.js" export class Sender extends Address { private readonly _messageFormat: MessageFormat private readonly _canLookupEmailAddress: boolean private readonly _senderIsCreator: boolean constructor( email: string, displayName: string, addressType: AddressType = "SMTP", messageFormat: MessageFormat = MessageFormat.TextAndHtml, canLookupEmailAddress: boolean = false, senderIsCreator: boolean = true, ) { super(email, displayName, addressType) this._messageFormat = messageFormat this._canLookupEmailAddress = canLookupEmailAddress this._senderIsCreator = senderIsCreator } writeProperties(stream: TopLevelProperties) { if (this._senderIsCreator) { stream.addProperty(PropertyTags.PR_CreatorEmailAddr_W, this.email) stream.addProperty(PropertyTags.PR_CreatorSimpleDispName_W, this.displayName) stream.addProperty(PropertyTags.PR_CreatorAddrType_W, this.addressType) } const senderEntryId = new OneOffEntryId(this.email, this.displayName, this.addressType, this._messageFormat, this._canLookupEmailAddress) stream.addProperty(PropertyTags.PR_SENDER_ENTRYID, senderEntryId.toByteArray()) stream.addProperty(PropertyTags.PR_SENDER_EMAIL_ADDRESS_W, this.email) stream.addProperty(PropertyTags.PR_SENDER_NAME_W, this.displayName) stream.addProperty(PropertyTags.PR_SENT_REPRESENTING_NAME_W, this.displayName) stream.addProperty(PropertyTags.PR_SENDER_ADDRTYPE_W, this.addressType) } }