private void parseEmailProperties()

in community/document-readers/spring-ai-alibaba-starter-document-reader-email/src/main/java/com/alibaba/cloud/ai/reader/email/msg/MsgParser.java [74:143]


	private void parseEmailProperties(MAPIMessage msg, MsgEmailElement email) {
		try {
			// Subject
			try {
				email.setSubject(msg.getSubject());
			}
			catch (ChunkNotFoundException e) {
				// maybe not found
				logger.debug("Subject not found in MSG file");
			}

			// From
			try {
				String fromAddress = msg.getDisplayFrom();
				if (fromAddress != null) {
					email.setFrom(fromAddress);
				}
			}
			catch (ChunkNotFoundException e) {
				logger.debug("From address not found in MSG file");
			}

			// From Name
			try {
				String fromName = msg.getDisplayFrom();
				if (fromName != null) {
					email.setFromName(fromName);
				}
			}
			catch (ChunkNotFoundException e) {
				logger.debug("From name not found in MSG file");
			}

			// To
			try {
				String[] recipients = msg.getRecipientEmailAddressList();
				if (recipients != null && recipients.length > 0) {
					email.setTo(recipients[0]);
				}
			}
			catch (ChunkNotFoundException e) {
				logger.debug("To address not found in MSG file");
			}

			// To Name
			try {
				String recipientName = msg.getRecipientNames();
				if (recipientName != null) {
					email.setToName(recipientName);
				}
			}
			catch (ChunkNotFoundException e) {
				logger.debug("To name not found in MSG file");
			}

			// Date
			try {
				if (msg.getMessageDate() != null) {
					email.setDate(msg.getMessageDate().toString());
				}
			}
			catch (ChunkNotFoundException e) {
				logger.debug("Date not found in MSG file");
			}
		}
		catch (Exception e) {
			logger.error("Error parsing email properties", e);
			throw new RuntimeException("Error parsing email properties", e);
		}
	}