def check_and_update_eml(self, part):
    if self._config[PROC_EMAIL_JSON_EXTRACT_EMAIL_ATTACHMENTS]:
        tmp_dir = None
        msg = None
        file_extension = ''
        try:
            tmp_dir = tempfile.mkdtemp(prefix='ph_email')
            filename = self._get_file_name(part.get_filename())
            (_, file_extension) = os.path.splitext(filename)
            if filename.endswith('.eml'):
                file_path = os.path.join(tmp_dir, filename)
                msg = part.get_payload()[0]
                with open(file_path, 'wb') as f:
                    f.write(msg.as_bytes())
                self._attachments.append({'file_name': filename, 'file_path': file_path})
        except IOError as e:
            error_msg = str(e)
            if ('File name too long' in error_msg):
                self.write_with_new_filename(tmp_dir, msg, file_extension, self._attachments, as_byte=True)
            else:
                self._base_connector.debug_print('Failed to write file: {}'.format(e))
        except Exception as e:
            self._base_connector.debug_print('Exception occurred: {}'.format(e))
def check_and_update_eml(self, part):
    if self._config[PROC_EMAIL_JSON_EXTRACT_EMAIL_ATTACHMENTS]:
        tmp_dir = None
        msg = None
        file_extension = 
        try:
            tmp_dir = tempfile.mkdtemp(prefix='ph_email')
            filename = self._get_file_name(part.get_filename())
            (_, file_extension) = os.path.splitext(filename)
            if filename.endswith('.eml'):
                file_path = os.path.join(tmp_dir, filename)
                msg = part.get_payload()[0]
                with open(file_path, 'wb') as f:
                    f.write(msg.as_bytes())
                self._attachments.append({'file_name': filename, 'file_path': file_path})
        except IOError as e:
            error_msg = str(e)
            if ('File name too long' in error_msg):
                self.write_with_new_filename(tmp_dir, msg, file_extension, self._attachments, as_byte=True)
            else:
                self._base_connector.debug_print('Failed to write file: {}'.format(e))
        except Exception as e:
            self._base_connector.debug_print('Exception occurred: {}'.format(e))