Thanks Nick

So should this work?


import logging, email
from google.appengine.ext import webapp
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class Greeting(db.Model):
    content = db.StringProperty(multiline=False)

class LogSenderHandler(InboundMailHandler):
    def receive(self, mail_message):
        logging.info("Received a message from: " + mail_message.sender)
        greeting = Greeting()
        greeting.content = mail_message.subject
        greeting.put()


I have tried this and this does not work, I have also tried using
greeting.content = "some" just to make sure its not a problem with
mail_message.subject but still no joy.

If I greeting.content in a seperate class it does write to the datastore but
I am unable to use the mail_message.sender value.

Sorry for being a bit simple



------------
Jon Byrne
[email protected]



On 31 March 2010 11:25, Nick Johnson (Google) <[email protected]>wrote:


> Hi Jon,
>
>
>  On Wed, Mar 31, 2010 at 11:19 AM, Jon Byrne <[email protected]> wrote:
>
>
>> Thanks for that I have sorted that side of things but am struggling to get
>> the email into the datastore.
>>
>>
>> I am using this code
>>
>>
>>
>>
>>  import logging, email
>>
>>  from google.appengine.ext import webapp
>>
>>  from google.appengine.ext.webapp.mail_handlers import
>> InboundMailHandler
>>
>>  from google.appengine.ext.webapp.util import run_wsgi_app
>>
>>  from google.appengine.ext import db
>>
>>
>>
>>  class Greeting(db.Model):
>>
>>      content = db.StringProperty(multiline=False)
>>
>>
>>
>>  class LogSenderHandler(InboundMailHandler):
>>
>>      def receive(self, mail_message):
>>
>>          logging.info("Received a message from: " + mail_message.sender)
>>
>>          greeting = Greeting()
>>
>>          greeting.content = mail_message.subject
>>
>>
> This code creates a new Greeting, and sets the content, but never saves it
> to the datastore. You need to call .put() on 'greeting'.
>
>
>>
>>
>>  class Guestbook(webapp.RequestHandler):
>>
>>         def importsender(self):
>>
>>          greeting = Greeting()
>>
>>          greeting.put()
>>
>>
> ...while this code creates a new, empty greeting, and saves it to the
> datastore, which probably doesn't do what you want it to.
>
> -Nick
>
>
>>
>> But do not get anything in the datastore or an error. Where am I going
>> wrong?
>>  ------------
>> Jon Byrne
>> [email protected]
>>
>>
>>
>>   On 31 March 2010 05:08, dhruvbird <[email protected]> wrote:
>>
>>
>>> You can configure you mail program receiving email to forward all
>>> incoming email (or some subset of it) to you appspot email ID.
>>> For example, if you ar eusing gmail or google apps, you can configure
>>> mail forwarding on the settings page or email page if you are an admin
>>> for your apps domain.
>>> From there you can do anything you want with it.
>>>
>>> Regards,
>>> -Dhruv.
>>>
>>>   On Mar 30, 10:54 pm, Jon Byrne <[email protected]> wrote:
>>> > I am a beginner @ Python and not an experienced developer, but I have
>>> an
>>> > idea to create an app using Google App Engine.
>>> >
>>> > The idea is that I forward some automatically generated emails from
>>> another
>>> > programme to my appspot app and then import them into the Data Store. I
>>> will
>>> > then from the data contained in the email be able to display the
>>> information
>>> > on the web in a usful fasion.
>>> >
>>> > Now the emails are standardised and come from the same address.
>>> >
>>> > Is there some sample code out there with this kind of thing or is it
>>> even
>>> > possible.
>>> >
>>> > Thanks
>>> >
>>> > ------------
>>> > Jon Byrne
>>>
>>> > [email protected]
>>>
>>>   --
>>> You received this message because you are subscribed to the Google Groups
>>> "Google App Engine" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected]<google-appengine%[email protected]>
>>> .
>>> For more options, visit this group at
>>> http://groups.google.com/group/google-appengine?hl=en.
>>>
>>>
>>>
>>
>>
>> --
>>
>> You received this message because you are subscribed to the Google Groups
>> "Google App Engine" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<google-appengine%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/google-appengine?hl=en.
>>
>>
>
>
> --
> Nick Johnson, Developer Programs Engineer, App Engine Google Ireland Ltd.
> :: Registered in Dublin, Ireland, Registration Number: 368047
> Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number:
> 368047
>
>
> --
>
>  You received this message because you are subscribed to the Google Groups
> "Google App Engine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<google-appengine%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/google-appengine?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en.

Reply via email to