Android Question Control Where Email Attachments Are Saved When Received On the Device

Mahares

Expert
Licensed User
Longtime User
Someone sends an email with attachments from their PC to a device. I need to develop an application on the device that automatically opens Gmail and saves the attachments ( up to 6 files at a time) in a specific folder, say File.DirRootExternals & “/MyFolder”. FTP is not an option in this situation. Have there been any successful ideas or projects on this subject and where I should start?
Thank you
 

Mahares

Expert
Licensed User
Longtime User
I modeled the attached project based on Erel’s sample in the POP3 and mailparser link provided by the good person in Reinhard. I cannot seem to download any files. No attachments get downloaded to the proper folder, in this case File.DirRootExternal.. I send emails with normal attachment extensions like : .tab or .txt.. Furthermore, I only want certain emails where the attachment file ends with .tab to be downloaded. I am not even interested in the message itself or any other files with other extensions. Can I achieve this? Can someone check my project and see if it can be corrected.
Thank you
 

Attachments

  • Pop3mailParserSampleMahares.zip
    8.6 KB · Views: 191
Upvote 0

rboeck

Well-Known Member
Licensed User
Longtime User
I have tried your project, i only changed the one line with the pop3 username and passwords. Everything worked; check only line 50 in POP_DownloadCompleted - currently you use File.DirRootExternal.
Your filter problem has to be solved inside MailParser; the code here is complex...

Reinhard
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Thank you both for taking a look at the code. I just cant's seem to see any files in the externalroot after running the program. When I open the email on the device, the messages are there along with the attachment files. Can you describe exactly your procedure on how to check it. Here is the debug log on the last 3 messages:
4
[Attachments=(ArrayList) [], BCCField=, Body=
, CCField=, ContentType= multipart/mixed;, FromField= " my name here " < myemailaddress.net >
, ToField= < device owner email [email protected] >, Subject= My file, IsInitialized=true
]
5
[Attachments=(ArrayList) [], BCCField=, Body=
, CCField=, ContentType= multipart/mixed;, FromField= "my name here" <myemailaddress.net>
, ToField= <device owner email [email protected]>, Subject= FW, IsInitialized=true
]
6
[Attachments=(ArrayList) [], BCCField=, Body=
, CCField=, ContentType= multipart/mixed;, FromField= " my name here " < myemailaddress.net >
, ToField= < device owner email [email protected] >, Subject= FW, IsInitialized=true
]
** Activity (main) Pause, UserClosed = false **
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
You should go with the debugger step by step and see what happens during the parsing.


How do you do that in this project? The log shows the array of attachment is blank for every message, despite the existence of attachments. These are very simple emails that have a short subject and practically nothing in the body. All I am interested in is to harvest the attachments and save them to the root external or one of its subfolders.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I changed the user and password to be my account credentials, then ran the program and was able to download a few attachments from my Gmail server. However, when I tried to send myself a message with an attachment to myself and ran the program again, it downloaded the same attachments as in the first run, but the last attachment I was expecting from my last email did not show up in the list of downloaded files. Is there a delay as to when the Gmail server releases it or what.

EDIT: I started using Gmail to compose the emails and attachments destined for the device and now I can see the attachments as expected. I was using Outlook before and for some reason staying with Gmail offered more compatibility. I will continue to investigate why Outlook did not deliver.
 
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I emailed to the device a message with 6 file attachments in the morning. The attachments were saved in the proper device folder using the mailparser program. Later in the day, I sent another email with 6 new attachments. The attachments have the same names as sent in the morning, but with new data. How do I insure that the files sent later in the day overwrite the older files when the message is retrieved on the device. That is what I would like to achieve: Overwrite attachments with the same name.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
@Erel; Thank you for taking interest in this important topic: Still not clear on 2 items:
1. The Attachments file names do not change from email to email , but the subject and/or the body text may change. I am presuming that the files still get overwritten, I hope.
2. Every time I send the email using Outlook 2007 no attachments get overwritten or even saved to the device. But when I use Gmail to send the message with its attachments, the files get saved to the device. Does the MailParser work only when using Gmail as the sending program?
 
Upvote 0
Top