×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    5

    Cool auto reply sms problem

    hello guys.. i have an automatic reply sms but when i run it it has a problem said that
    "IndexError: list index out of range"
    i dont know how to fix it...

    here's my code

    Code:
    import messaging, inbox, time, contacts
    
    box = inbox.Inbox(inbox.EInbox)
    
    def any(string1, string2):
        for i in range(len(string2)-1):
            if string1.find(string2[1:1+1])>-1:
                return True
        return False
    
    def autoreply(messageID):
        time.sleep(5)
        sender = box.address(messageID)
        text = box.content(messageID)
        if not any(sender, "0123456789"):
            db = contacts.open()
            firstName = sender.split(" ")[0]
            lastName = sender.split(" ")[-1]
            contactList = db.find(firstName)
            for contact in contactList:
                if contact.find("last_name")[1].value == lastName:
                    phoneNumber = contact.find('phone_number')[0].value
                    reply = sender + \
                            ", I am not able to read your message at this time." + \
                            "  I will respond soon."
                    print 'Sending "'+reply+'" to '+phoneNumber
                    messaging.sms_send(phoneNumber, reply)
                    break
    
    box.bind(autoreply)
    please help me guys...

    thank you for advance...
    i hope you'll help me..

  2. #2
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: auto reply sms problem

    The error should also say the line at which it occurs. Please post the exact error message.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    5

    Re: auto reply sms problem

    hello bogdan.galiceanu thank you for the response

    im sorry for the incomplete information..


    when i run the program then i try to text then i'll waiting for the automatic reply and nothings happen


    the error said

    traceback(most recent call last):
    file "e\python\smsautoreply.py", line 21
    in autoreply
    if contact.find("last_name")[1].value == lastName:
    "IndexError: list index out of range"


    please try to edit my code...
    i hope you'll help me...

    thank you again in advance..
    Last edited by whitestich02; 2011-02-20 at 11:08.

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: auto reply sms problem

    Well, your contact most likely has only 1 last_name field. So you should use contact.find("last_name")[0] (because in Python list positions start at 0).

  5. #5
    Registered User
    Join Date
    Feb 2011
    Posts
    5

    Re: auto reply sms problem

    thank you for your reply...

    but i'll try to change to contact.find("last_name")[0]

    but nothings happen...

    same error with

    traceback(most recent call last):
    file "e\python\smsautoreply.py", line 21
    in autoreply
    if contact.find("last_name")[0].value == lastName:
    "IndexError: list index out of range"

    help me to fix it.. thank you for advance

  6. #6
    Super Contributor
    Join Date
    Oct 2007
    Location
    Deva, Romania
    Posts
    3,471

    Re: auto reply sms problem

    That's odd... could it be that that contact doesn't have a last_name field? Please pick a contact from your phone book (one that has a last name) and test this code on it:
    Code:
    contactList = db.find(lastName)  #Give lastName the value of the contact's last name field
    for contact in contactList:
        if len(contact.find("last_name")) == 0:
            print "No last name field"
        elif contact.find("last_name")[0].value == lastName:
            print "Found it"
    That way we'll at least know if it works for a contact that we know for sure has a last_name field.

Similar Threads

  1. I can know if an incoming sms is reply of an sent sms???
    By isantosp in forum [Archived] Qt Mobility Project
    Replies: 1
    Last Post: 2010-07-07, 13:52
  2. Auto reply sms Need help
    By prakash3p in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2010-03-03, 11:36
  3. SMS request a reply??
    By usc2424 in forum General Messaging
    Replies: 3
    Last Post: 2007-12-19, 12:18
  4. HELP !auto-reply sms system (using 8250 & VB6)
    By dancingqueeneng in forum PC Suite API and PC Connectivity SDK
    Replies: 4
    Last Post: 2007-02-08, 07:08
  5. Identifying a sms reply
    By jhj_itp in forum General Messaging
    Replies: 1
    Last Post: 2003-08-07, 05:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×