Python unable to convert eml file to PST getting Error Reason: Proxy error(ArgumentNullException): Could not find the data block by its identifier. (Parameter 'entry')

We are trying to convert a eml file downloaded to PST format, but getting below error

Reason: Proxy error(ArgumentNullException): Could not find the data block by its identifier. (Parameter ‘entry’)

Below is the code

from aspose.email import MailMessage
from aspose.email.mime import HeaderCollection
import aspose.email.mapi.msg as msg
from aspose.email.mapi import MapiMessage, MapiContact
from aspose.email.personalinfo.vcard import VCardContact

def run():

	#dataDir = "Data/"
	#ExStart: LoadingContactFromVCardWithSpecifiedEncoding
	mailReadFromFile = MapiMessage.from_mail_message(MailMessage.load("test.eml"))
	#ExEnd: LoadingContactFromVCardWithSpecifiedEncoding
	
if __name__ == '__main__':
    run()

Can we get RCA for this error ? why this error is shown and how can be aviod this ? or any fix that can be done ?

@TejasA

The error you’re encountering, “Proxy error(ArgumentNullException): Could not find the data block by its identifier,” typically indicates that the conversion process is unable to locate a specific data block in the EML file. This can happen for several reasons, such as:

  1. Corrupted EML File: The EML file might be corrupted or not properly formatted, which can lead to issues during the conversion process.
  2. Unsupported Features: The EML file may contain features or elements that are not supported by the conversion library.
  3. Incorrect Entry ID: If the entry ID being referenced does not exist or is invalid, it can trigger this error.

Diagnosis & Next Steps:

  1. Check the EML File: Ensure that the EML file is not corrupted. Open it in an email client to verify its integrity.
  2. Use Load Options: When loading the EML file, use specific load options to handle any peculiarities in the file. For example:
    from aspose.email import EmlLoadOptions
    
    load_options = EmlLoadOptions()
    mail_read_from_file = MapiMessage.from_mail_message(MailMessage.load("test.eml", load_options))
    
  3. Update Aspose Library: Ensure you are using the latest version of the Aspose.Email library, as updates often include bug fixes and improved support for various formats.
  4. Test with Different EML Files: Try converting a different EML file to determine if the issue is specific to the file you are currently using.

If the problem persists after these steps, please provide additional details about the EML file or any specific features it contains. I am here to assist you further. Let me know how it goes!

The EML file is valid and not corrupted, Please suggest how we can fix this

Hello @TejasA,

The code snippet you shared does not include any PST operations, while the error you mentioned occurs when adding an EML to a PST. Could you please provide the actual code where you use the PST and add the message, and if possible, also share a sample EML file that reproduces the issue? That will help us investigate and give you an exact solution.

Thank you.

@margarita.samodurova

Please find the eml file for which we are seeing error.

You’ve joined the test_yad_group_8 group.eml.zip (240.3 KB)

Aspose version we are using : Aspose.Email_for_Python_via_NET_rebuild_with_22_upgraded_linux_version-22.12-py3-none-any.whl

@TejasA,

Thanks for sharing the EML file.
However, to be able to reproduce the issue, we will also need the code snippet you are using to add this EML into a PST.
The code you posted earlier doesn’t contain any PST-related operations, while the exception you reported occurs at the PST insertion step.

@margarita.samodurova Please find the code to repoduce this issue. Input will be the eml file and output pst

import sys
import io
from aspose.email.mapi import MapiMessage
from aspose.email.storage.pst import PersonalStorage, FileFormatVersion

def convert_eml_to_pst(eml_path, pst_path):
    # Read EML file
    with open(eml_path, 'rb') as f:
        eml_content = f.read()
    
    # Create PST file
    pst = PersonalStorage.create(pst_path, FileFormatVersion.UNICODE)
    inbox = pst.root_folder.add_sub_folder("Inbox", True)
    
    # Convert EML to MAPI message and add to PST
    stream = io.BytesIO(eml_content)
    mapi_msg = MapiMessage.from_stream(stream)
    inbox.add_message(mapi_msg)
    
    pst.dispose()
    print(f"Converted {eml_path} → {pst_path}")

if __name__ == "__main__":
    if len(sys.argv) != 3:
        print("Usage: python simple_eml_to_pst.py input.eml output.pst")
        sys.exit(1)
    convert_eml_to_pst(sys.argv[1], sys.argv[2])

@TejasA,

Thank you for your code. We will review it and get back to you shortly.

Hello @TejasA,

We’ve tested your case with the latest version of Aspose.Email for Python via .NET and were not able to reproduce the error you mentioned.

One important note: the method MapiMessage.from_stream is no longer available. Instead, you should use MapiMessage.load when loading messages from a stream or file.

So please update your code to use load instead of from_stream and check if the issue still occurs with the latest version of the library.

@margarita.samodurova thanks for checking this.
Can you please share which Aspose version was used to test this ?

@TejasA,

Aspose.Email-for-Python-via-NET 25.8

@margarita.samodurova thanks for the respose.

Can you also please check with below attach eml file this fix will work or not ?

EMLs.zip (1.3 KB)

@TejasA,

Sure, we’ll check it and get back to you with the result.

Hello @TejasA ,

We have checked with the attached EML file, and everything works fine.

@margarita.samodurova Thanks for the confirmation.

@TejasA,

You are welcome.