def _handle_body(self, body, parsed_mail, email_id):
    local_file_path = body['file_path']
    ips = parsed_mail[PROC_EMAIL_JSON_IPS]
    hashes = parsed_mail[PROC_EMAIL_JSON_HASHES]
    urls = parsed_mail[PROC_EMAIL_JSON_URLS]
    domains = parsed_mail[PROC_EMAIL_JSON_DOMAINS]
    file_data = None
    try:
        with open(local_file_path, 'r') as f:
            file_data = f.read()
    except Exception:
        with open(local_file_path, 'rb') as f:
            file_data = f.read()
        self._base_connector.debug_print('Reading file data using binary mode')
    if ((file_data is None) or (len(file_data) == 0)):
        return phantom.APP_ERROR
    file_data = UnicodeDammit(file_data).unicode_markup.encode('utf-8').decode('utf-8')
    self._parse_email_headers_as_inline(file_data, parsed_mail, email_id)
    if self._config[PROC_EMAIL_JSON_EXTRACT_DOMAINS]:
        emails = []
        emails.extend(re.findall(email_regexc, file_data))
        emails.extend(re.findall(email_regexc2, file_data))
        for curr_email in emails:
            domain = curr_email[(curr_email.rfind('@') + 1):]
            if (domain and (not ph_utils.is_ip(domain))):
                domains.add(domain)
    self._extract_urls_domains(file_data, urls, domains)
    if self._config[PROC_EMAIL_JSON_EXTRACT_IPS]:
        self._get_ips(file_data, ips)
    if self._config[PROC_EMAIL_JSON_EXTRACT_HASHES]:
        hashs_in_mail = re.findall(hash_regexc, file_data)
        if hashs_in_mail:
            hashes |= set(hashs_in_mail)
    return phantom.APP_SUCCESS
def _handle_body(self, body, parsed_mail, email_id):
    local_file_path = body['file_path']
    ips = parsed_mail[PROC_EMAIL_JSON_IPS]
    hashes = parsed_mail[PROC_EMAIL_JSON_HASHES]
    urls = parsed_mail[PROC_EMAIL_JSON_URLS]
    domains = parsed_mail[PROC_EMAIL_JSON_DOMAINS]
    file_data = None
    try:
        with open(local_file_path, 'r') as f:
            file_data = f.read()
    except Exception:
        with open(local_file_path, 'rb') as f:
            file_data = f.read()
        self._base_connector.debug_print('Reading file data using binary mode')
    if ((file_data is None) or (len(file_data) == 0)):
        return phantom.APP_ERROR
    file_data = UnicodeDammit(file_data).unicode_markup.encode('utf-8').decode('utf-8')
    self._parse_email_headers_as_inline(file_data, parsed_mail, email_id)
    if self._config[PROC_EMAIL_JSON_EXTRACT_DOMAINS]:
        emails = []
        emails.extend(re.findall(email_regexc, file_data))
        emails.extend(re.findall(email_regexc2, file_data))
        for curr_email in emails:
            domain = curr_email[(curr_email.rfind('@') + 1):]
            if (domain and (not ph_utils.is_ip(domain))):
                domains.add(domain)
    self._extract_urls_domains(file_data, urls, domains)
    if self._config[PROC_EMAIL_JSON_EXTRACT_IPS]:
        self._get_ips(file_data, ips)
    if self._config[PROC_EMAIL_JSON_EXTRACT_HASHES]:
        hashs_in_mail = re.findall(hash_regexc, file_data)
        if hashs_in_mail:
            hashes |= set(hashs_in_mail)
    return phantom.APP_SUCCESS