def new_message(self, recipient=None, *, recipient_type=RecipientType.TO):
        """ This method returns a new draft Message instance with
        contacts first email as a recipient

        :param Recipient recipient: a Recipient instance where to send this
         message. If None first email of this contact will be used
        :param RecipientType recipient_type: section to add recipient into
        :return: newly created message
        :rtype: Message or None
        """
        if self.main_resource == GAL_MAIN_RESOURCE:
            # preventing the contact lookup to explode for big organizations..
            raise RuntimeError('Sending a message to all users within an '
                               'Organization is not allowed')

        if isinstance(recipient_type, str):
            recipient_type = RecipientType(recipient_type)

        recipient = recipient or self.emails.get_first_recipient_with_address()
        if not recipient:
            return None

        new_message = self.message_constructor(parent=self, is_draft=True)

        target_recipients = getattr(new_message, str(recipient_type.value))
        target_recipients.add(recipient)

        return new_message
def new_message ( self , recipient = None , * , recipient_type = RecipientType . TO ) : if self . main_resource == GAL_MAIN_RESOURCE : raise RuntimeError ( 'Sending a message to all users within an ' 'Organization is not allowed' ) if isinstance ( recipient_type , str ) : recipient_type = RecipientType ( recipient_type ) recipient = recipient or self . emails . get_first_recipient_with_address ( ) if not recipient : return None new_message = self . message_constructor ( parent = self , is_draft = True ) target_recipients = getattr ( new_message , str ( recipient_type . value ) ) target_recipients . add ( recipient ) return new_message
This method returns a new draft Message instance with
        contacts first email as a recipient

        :param Recipient recipient: a Recipient instance where to send this
         message. If None first email of this contact will be used
        :param RecipientType recipient_type: section to add recipient into
        :return: newly created message
        :rtype: Message or None