Android Question Sending email and tracking responses with SMTP from Net [lib]

Discussion in 'Android Questions' started by AscySoft, Feb 8, 2015.

  1. AscySoft

    AscySoft Active Member Licensed User

    Hi.
    I need to capture some shots on the go and send them to some predefined email addresses.
    After a file(picture file) is created I need to send an info email on a yahoo address with description etc and another email to a gmail account with attachment.
    So when a picture is taken, 2 mails are created and are sended one after another.

    After that I want to delete files that were successfully sended, but I don't know hot to do that.
    The SMTP.MessageSent is tracking only the status of a (I should say last?) email sent.
    Imagine if user is trying to take 5 photos one after another(10 emails). Emails with pictures will go less slower than the rest of them, and with 3G even slower.

    How do I know which picture was successful sended and which is pending or something else?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    1. Create a list with the data you want to send (one item for each message).
    2. Send the first message.
    3. In MessageSent event remove the first item from the list and send the next item.

    When the list is empty you know that you have sent all messages.
     
    AscySoft likes this.
  3. AscySoft

    AscySoft Active Member Licensed User

    Clever. I will try that. Thanks.
    I am very tired with my first newborn son. I don't sleep to well/ I will post when I can.
    BTW. Do you think that it is better to store all files in a list and send them all together?
    Another thing: on point 3, what if message was failed, do you thing I should retry sending again and again the same mail?
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Are you sending all the files to the same destination? If the files are not too large then it is better to send them in a single mail.

    As you have all the data in the list of messages you can easily create another list with the failed messages and then ask the user whether he wants to send them again.
     
  5. AscySoft

    AscySoft Active Member Licensed User

    Update: I create a service, and with it I was able to send all the files I wanted even if the app was closeed. Thanks for the reply.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Tip: Call Service.StartForeground and stop it when you finish sending the messages.
     
  7. AscySoft

    AscySoft Active Member Licensed User

    I actually start it when my app was first lounch with StartService and in service if it fails (by various reasons, no data files to send, no data connection etc) restart it with StartServiceAt... but thanks for the tip.
    One quick question: lets say some user connect his device to a computer (usual check for new data, push data, copy data etc, and sometimes update the app using a adb command)
    I was not able to test (yet) if adb - install -r ...apk will throw error if in that particular moment the service is running. Do you have a clue/advice?
    Thanks very much.
     
    Last edited: Feb 11, 2015
  8. Erel

    Erel Administrator Staff Member Licensed User

    There will be no error. The process will be killed.
     
  9. AscySoft

    AscySoft Active Member Licensed User

    Well, then my work is completed. A big thanks goes to you.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice