JMore
JMore

Reputation: 1

Spark On-Prem EWS - CDATA JDBC read returning a null body and no attachment list

I am trying to receive the body and attachments IDs of an email from an EWS On-Prem server using the CDATA JDBC driver, however, it is always coming back null. The Subject line, ItemId, dates, and involved email addresses all come back correctly. CDATA documentation states that I should be seeing content through a conventional query. The Spark version is 3.0.0 and the scala version is 2.12.12. Is there a permission the admin account is missing that allows it to see an email body specifically or is this a known problem?

var query = "select Body, UniqueBody, UniqueBodyType, Attachments, HasAttachments FROM Inbox"

val df = spark.sqlContext.read.format("jdbc")
          .option("url", url)
          .option("query", query)
          .option(DRIVER, CDATA_EXCHANGE_DRIVER)
          .load()

result stored in dataframe

Upvotes: 0

Views: 54

Answers (1)

Anil
Anil

Reputation: 24

The admin account used to access the Exchange server may lack the required permissions to view email bodies or attachments. make sure that the account has the following roles: Application Impersonation: Grants access to impersonate users and read their mailbox data. Mailbox Search: Provides read access to mailbox contents.

It is always good to keep an eye on the CData driver documentation. They have a lot of connection properties to control almost everything. IncludeContent property must be explicitly enabled in your JDBC connection setup to retrieve additional content, such as the Body field of an email in the Inbox

By default, retrieving additional content (like the Body field) is disabled because it can be expensive in terms of performance and resource usage. Explicitly enabling IncludeContent ensures that only users who are aware of the performance trade-offs retrieve such data.

here's the link to the online doc: https://cdn.cdata.com/help/CEK/jdbc/RSBExchange_p_IncludeContent.htm

Older versions of EWS may not fully support certain fields (e.g., UniqueBody or Attachments). You can test fetching the same fields using a direct EWS API tool (like Postman or a Python script using exchangelib) to confirm whether the issue is server-related or driver-related.

Upvotes: 0

Related Questions