On Wed, Jul 29, 2009 at 9:08 AM, el_kolo <el_k...@interia.pl> wrote:

>
> Hi,
>
> I have a form (class myForm(forms.Form)) with a few fields. I want to
> send this form to my email account. I have put this form to my
> template with button SEND. Everything works fine but using send_mail
> function I can send only ONE field from my from to my email account.
> send_mail('Subject here', 'Here is the message', 'f...@example.com',
> ['t...@example.com'], fail_silently=False)
>
> Do you know how to send whole form or 2-3 fields?
>
> Hi
Take a look at django-contact-form:
http://code.google.com/p/django-contact-form/source/browse/trunk/contact_form/forms.py

    def get_message_dict(self):
        if not self.is_valid():
            raise ValueError("Message cannot be sent from invalid contact
form")
        message_dict = {}
        for message_part in ('from_email', 'message', 'recipient_list',
'subject'):
            attr = getattr(self, message_part)
            message_dict[message_part] = callable(attr) and attr() or attr
        return message_dict

    def save(self, fail_silently=False):
        """
        Builds and sends the email message.

        """
        send_mail(fail_silently=fail_silently, **self.get_message_dict())


Best Regards,
Steve
http://agilitynerd.com
http://googility.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to