def _set_emails(<EOL>self, emails, global_substitutions=None, is_multiple=False, p=<NUM_LIT:0>):
<EOL>if is_multiple is True:<EOL><INDENT>if isinstance(emails, list):<EOL><INDENT>for email in emails:<EOL><INDENT>personalization = Personalization()<EOL>personalization.add_email(email)<EOL>self.add_personalization(personalization)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>personalization = Personalization()<EOL>personalization.add_email(emails)<EOL>self.add_personalization(personalization)<EOL><DEDENT>if global_substitutions is not None:<EOL><INDENT>if isinstance(global_substitutions, list):<EOL><INDENT>for substitution in global_substitutions:<EOL><INDENT>for p in self.personalizations:<EOL><INDENT>p.add_substitution(substitution)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>for p in self.personalizations:<EOL><INDENT>p.add_substitution(global_substitutions)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>personalization = self._personalizations[p]<EOL>has_internal_personalization = True<EOL><DEDENT>except IndexError:<EOL><INDENT>personalization = Personalization()<EOL>has_internal_personalization = False<EOL><DEDENT>if isinstance(emails, list):<EOL><INDENT>for email in emails:<EOL><INDENT>personalization.add_email(email)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>personalization.add_email(emails)<EOL><DEDENT>if global_substitutions is not None:<EOL><INDENT>if isinstance(global_substitutions, list):<EOL><INDENT>for substitution in global_substitutions:<EOL><INDENT>personalization.add_substitution(substitution)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>personalization.add_substitution(global_substitutions)<EOL><DEDENT><DEDENT>if not has_internal_personalization:<EOL><INDENT>self.add_personalization(personalization, index=p)<EOL><DEDENT><DEDENT>
Adds emails to the Personalization object

        :param emails: An Email or list of Email objects
        :type emails: Email, list(Email)
        :param global_substitutions: A dict of substitutions for all recipients
        :type global_substitutions: dict
        :param is_multiple: Create a new personilization for each recipient
        :type is_multiple: bool
        :param p: p is the Personalization object or Personalization object
                  index
        :type p: Personalization, integer, optional