Issues printing email content sent with python in Android - Android Studio

I'm making an android application that has to take an email, which has been sent via a python script to a gmail account, and search the subject and message body for certain phrases. I haven't had any problem setting up the email services (I'm using the smtp library to send in python, and javamail IMAP to read in android studio), or sending and opening the emails themselves. I've also been able to search the subject for whatever phrase or character I want, but when I wrote some test code to try to print the message body, nothing gets printed. I've checked that the email is actually formatted properly by opening gmail in a browser, and the content is definitely there, but when I use javamail's getContent() and convert it to a string, nothing gets printed. I know that getContent() can be weird because it returns an object, but since the message I'm sending is just text, with no images or attachments, I thought just using toString() would work.
Here's the applicable code (with usernames and passwords removed)
Python:
Code:
message = """From: Sender <send address>
To: Receiver <receive address>
Subject: test
test message
"""
smtpObj = smtplib.SMTP('smtp.gmail.com')
smtpObj.starttls()
smtpObj.login(username, password)
smtpObj.sendmail(sender, receiver, message)
Android (I've skipped all the login and session code, because I know it works)
Code:
Message messages[] = inbox.getMessages();
System.out.println("Reading messages...");
for(Message message:messages) {
for (Address a: message.getFrom()){
System.out.println("From:" + a);
System.out.println("Title: " + message.getSubject());
System.out.println();
System.out.println(message.getContent().toString());
System.out.println("---");
}
}
Here's the printout in android studio when the message is opened:
I/System.out: From:Sender <send address>
I/System.out: Title: test
I/System.out: ---
So it just prints as if the content is null, but it is definitely there when I open the email in a browser. I'm sure I'm doing something wrong with message.getContent(), but everything I've looked up and tried has the same result. Any advice on how to properly print and store the content as a string, or properly use getContent() would be greatly appreciated. Thank You!

Related

Missing Message Body Text

I've just set up Gmail IMAP on my Kaiser, but I can't seem to get any of the message body to show. I've used the folder setup to specify the entire message to be downloaded including attachments.
On a test email I have sent with subject as "test test test" with the same message body. Also attached a 200k jpg file. My Gmail account downloaded the message, including the attachment - but no message body!?
Any ideas why the message body would be missing?
I'm pretty sure it's not a Gmail or IMAP issue, as I had this problem on my Hermes (Vario II) with a POP mail account.
Thanks,
FrankyG
I'm afraid it's a Gmail issue: http://groups.google.com/group/Gmai...8284ba446c/dc821659318f2bd2?q=imap+wm&lnk=ol&
I've just had this happen on my HTC Kaiser and I do NOT use Gmail...
E-mail was working fine for months. Now when I try and view any e-mail (POP, Windows Live or ActiveSync accounts) the "From", "To", and "Subject" fields are all visible as well as any e-mail attachments. However the body of the e-mail is entirely blank. Outlook is set to download the entire body so it's not a "headers only" issue.
Also SMS inbox works fine...so it is only e-mail.
I've tried deleting the cemail.vol database to see if it was a database corruption problem but it didn't resolve my problem.
Any ideas?

Pocket Outlook message templates

I have some standard information (client report) that I send into the office every day.
Is there any way I can create some kind of template message with headings that I can fill in each day?
Alternatively is there a way of putting carriage returns into My Text; that would do it.
Currently I'm using Mortscript to generate the message, but it's not as robust as I'd like.
Cheers
Can't you use a Word template and Email the resulting docx/rtf/txt file as an attachment?
Using attachments isn't really a good solution.
The client reports get emailed to the office where they arrive in a public folder. These are from time-to-time searched for certain strings, for example if we want to find a client who uses a particular piece of software. If the reports are in attachments the search won't work, I think.
Why don't you just build a shell or example in word or notepad. Then you could just copy and paste it in your email. It's an extra step but works ok.

Email count for Outlook E-mail ?

Hi,
Dose any know how i can get an Email count for Outlook E-mail ?
i am using wibar on my Tytn II and i have sorted out how to get the email count for two which are "gmail" and "fastmail" but as you know the Tytn has to check these every 30min or so (what ever time has been set) but i setup an account with mobipush which uses Outlook and that why i need the count for it if its possible.
i have used the method below from another forum
1. Create a shortcut (wherever) to \windows\tmail.exe.
2. Modify that shortcut so that it reads"
"\windows\tmail.exe" -service "AccountName"
AccountName should be exactly as it show up in your Accounts list. (When you're in tmail, click menu, then "Go to" and use the name as you see it there. I'm using this trick for POP accounts - I'm not sure if this will work for "Outlook E-mail". For Text Messages, of course, you use "SMS" and for Multimedia messages you use "MMS".)
Once you have the shortcut, just specify the filename for the .LNK file (e.g. "\My Documents\gmail.lnk") as the command for your (WAD) shortcut.
You can use the same principles to create a Text Object (which can sit on top of the icon that takes you to that e-mail account) which will show the unread message count for that account. Just create a text object with
Object Type: Custom Text
Text to display: %Unread:AccountName% (as above) and
Tap Action: .LNK file as above
now i did try this but with the account name of "Outlook E-mail" and "Outlook" but none of those seem to work.
if any of you clever members could get this working i would be very grateful.
Tony

SEVEN & Gmail -- can you archive and/or search email?

I've been messing around with SEVEN, and it seems to do everything I want (sync read/unread status, deletion) except I haven't found a way to archive email or search through All Mail.
Are those two things possible (or do you have to use the web interface or the java app)?
Seven treats gmail like any other imap server (at least for e-mail fetching functions, though I think the configuration is tweaked to deal with gmail's unique folder layout and have things work fairly seamlessly with what appear as "labels" in the gmail interface.
It also is limited to getting mail from a certain time period, instead of everything on g-mail's server.
So all you can view and search is what's from within that time period -- for anything else, you'll need the java app or web site.
Thanks for the info!
Too bad you can't archive email... There isn't a way to set up a label with a filter, so you can instead just move email into an archiving folder?
Also, is it possible to get the preview in TouchFlo 3D to show the content of the email? (it says "Click to view message" instead of showing me the head of the message).

[APK] ADT-1 Cast Receiver, Leanback Launcher & more

So I was attending I/O and got the ADT-1, Android TV development device. These are the APKs I was able to pull from it (interesting ones).
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
Download links:
Android Media Shell a.k.a. Google Cast Receiver. Doesn't work for me even on the ADT-1 itself although reports successful service start in logcat.
Leanback Launcher, the launcher in Android TV.
Launcher L I don't know what this exactly is, but from its contents it appears to be something like GEL or Google Now but with TV UI. There is a bunch of activities and some strange tutorial slides inside.
Leanback Keyboard, a keyboard that can be operated with a d-pad.
Brilliant! thanks for sharing.
Be interesting to see what becomes of this
Cheers Rob.
Looks like you're right - the Leanback Keyboard does require a d-pad. Probably would work good on a device like the NVIDIA SHIELD.
Cheers for the uploads!
Some folks are already having fun trying, but no luck so far:
darren1 said:
Grishka11 has posted the apk on this thread
http://forum.xda-developers.com/har...ast/apk-adt-1-cast-receiver-leanback-t2814210
Only installs on Kit Kat or Android L. Doesn't do anything on my Nexus 10 running 4.4.2. Decompiled and altered the minimum sdk version and installed it on a Jellybean Android box and again does nothing.
Click to expand...
Click to collapse
Ah well, maybe someone will crack it eventually.
The reason CheapCast stopped working was because of some kind of certificates the Chromecast SDK2.0 requires. I wonder if they could be pulled from a ADT-1 /system dump somehow..
@Grishka11 it's asking for permissions we don't have when installed, can you see if you can pull them from /system/etc/permissions?
Code:
W/PackageManager( 462): Unknown permission android.permission.ACCESS_DRM_CERTIFICATES in package com.google.android.apps.mediashell
W/PackageManager( 462): Unknown permission android.permission.HDMI_CEC in package com.google.android.apps.mediashell
osm0sis said:
@Grishka11 it's asking for permissions we don't have when installed, can you see if you can pull them from /system/etc/permissions?
Code:
W/PackageManager( 462): Unknown permission android.permission.ACCESS_DRM_CERTIFICATES in package com.google.android.apps.mediashell
W/PackageManager( 462): Unknown permission android.permission.HDMI_CEC in package com.google.android.apps.mediashell
Click to expand...
Click to collapse
Here you go
Grishka11 said:
Here you go
Click to expand...
Click to collapse
I cant find the permissions needed in the zip. Can you post the output from
Code:
$ adb shell pm list permissions -s
Command to see what permissions is installed on the ADT-1
mannberg said:
I cant find the permissions needed in the zip. Can you post the output from
Code:
$ adb shell pm list permissions -s
Command to see what permissions is installed on the ADT-1
Click to expand...
Click to collapse
Code:
[email protected]:/ $ pm list permissions -s
All Permissions:
Status Bar: expand/collapse status bar
Read User Dictionary: read terms you added to the dictionary
System tools: null, measure app storage space, get information on internal storage, null, read subscribed feeds, change background data usage setting, uninstall shortcuts, send package removed broadcast, Interact with update and recovery system, access extra location provider commands, install shortcuts, null, set screen compatibility, null, create internal storage, modify global animation speed, destroy internal storage, null, mount/unmount internal storage, read battery statistics, rename internal storage, send sticky broadcast, erase USB storage, retrieve details of running apps, null, interact across users, access USB storage filesystem, delete all app cache data, read/write to resources owned by diag, null, retrieve app ops statistics, mock location sources for testing, null, null, start any activity, force stop other apps, write subscribed feeds, full license to interact across users, null, null, modify system settings, change/intercept network settings and traffic, set preferred apps, manage users
Write User Dictionary: add words to user-defined dictionary
Microphone: record audio
Affects Battery: transmit infrared, allow Wi-Fi Multicast reception, prevent phone from sleeping, control flashlight, control vibration
Bookmarks and History: write web bookmarks and history, read your Web bookmarks and history
Storage: modify or delete the contents of your USB storage, read the contents of your USB storage, manage document storage, modify/delete internal media storage contents
Your accounts: view configured accounts, find accounts on the device, AdWords, Google mobile apps, contacts data in Google accounts, Personalized Speech Recognition, YouTube usernames, access other Google services, Google Checkout QA accounts, Google Notebook, iGoogle accounts, Google Docs, Google Voice Search, Android services, Google Base, Google mail, Google Maps, Dodgeball, Google Finance, create accounts and set passwords, Google Voice, Google Book Search, act as the AccountManagerService, Google Checkout accounts, JotSpot, Google Wi-Fi, Knol, read Google service configuration, YouTube, Google App Engine, Blogger, Orkut, Picasa Web Albums, add or remove accounts, access all Google services, Google Webmaster Tools, Google Health, Google News, Android services, Google Calendar, Google Talk, use accounts on the device, Google Spreadsheets, AdSense, Google Checkout Sandbox accounts, Google Groups
Audio Settings: change your audio settings
Wallpaper: adjust your wallpaper size, set wallpaper
Accessibility features:
Services that cost you money:
Clock: set time zone
Your social information: read call log, modify your contacts, read your contacts, read your social stream, write to your social stream, write call log
Your personal information: add or modify calendar events and send email to guests without owners' knowledge, null, Access all voicemails, activity recognition, read your own contact card, choose widgets, body sensors (like heart rate monitors), read calendar events plus confidential information, null, Browse launcher data, retrieve screen content, modify your own contact card
Bluetooth: access Bluetooth settings, allow Bluetooth pairing by Application, pair with Bluetooth devices
Lock screen: disable your screen lock
Development tools: limit number of running processes, access external storage of all users, change system display settings, send Linux signals to apps, force background apps to close, enable app debugging, read sensitive log data, modify secure system settings, retrieve system internal state
Phone calls: interact with in-call screen, read precise phone states, directly call phone numbers, null, reroute outgoing calls, read phone status and identity, modify phone state, make/receive Internet calls
Your location: null, approximate location (network-based), precise location (GPS and network-based)
Voicemail: add voicemail
Other Application UI: draw over other apps
Camera: take pictures and videos, disable transmit indicator LED when camera is in use
Sync Settings: read sync settings, toggle sync on and off, read sync statistics
Hardware controls: manage preferences and permissions for USB devices, test hardware, implement MTP protocol
Calendar:
Your applications information: close other apps, retrieve running apps, stop running apps, manage activity stacks, close other apps, reorder running apps, make app always run, run at startup
Network communication: connect and disconnect from WiMAX, receive data from Internet, change network connectivity, score networks, control Near Field Communication, Change WiMAX state, download files without notification, send and receive XMPP messages to and from Google servers, Broadcast data messages to apps., Google Play billing service, null, send and receive XMPP messages to and from Google servers, null, Google Play license check, Broadcast data messages to apps., Send heartbeat to Google Talk server, Broadcast XMPP messages to apps., view Wi-Fi connections, connect and disconnect from Wi-Fi, view network connections, null, Broadcast XMPP messages to apps., full network access
Alarm: set an alarm
Your messages: receive text messages (SMS), read cell broadcast messages, read instant messages, edit your text messages (SMS or MMS), Exchanges messages and receives sync notifications from Google servers., receive emergency broadcasts, receive text messages (WAP), send SMS messages, send respond-via-message events, write instant messages, send SMS-received broadcast, read your text messages (SMS or MMS), send WAP-PUSH-received broadcast, receive text messages (MMS)
ungrouped:
bind to an accessibility service, access InputFlinger, null, null, null, null, null, bind to a text service, bind to a VPN service, null, bind to a wallpaper, null, delete apps, listen for observations on network conditions, force phone reboot, use any media decoder for playback, bind to a condition provider service, run the application's scheduled background work, confirm a full backup or restore operation, access all print jobs, Access download manager., null, Send download notifications., bind to a print spooler service, Audio Routing, null, capture secure video output, Access keyguard secure storage, filter events, null, bind to a remote display, change screen orientation, modify network usage accounting, null, change pointer speed, move app resources, configure Wifi displays, directly call any phone numbers, permanently disable phone, Clear disk cache data, interact with a device admin, access content providers externally, update component usage statistics, Receive BT handover transfer broadcasts., directly start CDMA phone setup, null, retrieve window token, delete other apps' caches, control media playback and metadata access, copy content, null, start print service configuration activities, null, Modify Google settings, Hotword detection, modify the Google services map, power phone on or off, Provide a trust agent., Google Tasks, delete other apps' data, control location update notifications, manage app tokens, null, freeze screen, bind to a package verifier, null, bind to an input method, Google Map maker, get current app info, press keys and control buttons, retrieve frame statistics, modify app ops statistics, disable or modify status bar, read historical network usage, monitor and control all app launching, bind to a print service, control system backup and restore, Read Google settings, Send broadcasts to Android Market., Access all system downloads, null, null, bind to a voice interactor, access checkin properties, prevent app switches, null, temporary enable accessibility, Modify Google service configuration, Advanced download manager functions., null, Control displaying and hiding keyguard, add or remove a device admin, control Wifi displays, display unauthorized windows, bind to a route provider service, null, manage trusted credentials, null, Reserve space in the download cache, modify battery statistics, null, read frame buffer, reset system to factory defaults, force app to close, Bind to a trust agent service, invoke the carrier-provided configuration app, enable or disable app components, Manage TalkBack custom labels, Panoramio, Read and write Google Search settings, null, Listen to trust state changes., bind to a TV input, null, bind to a widget service, status bar, Google Reader, access serial ports, record what you type and actions you take, change keyboard layout, bind to NFC service, verify packages, access SurfaceFlinger, modify socket marks, null, null, grant or revoke permissions, Whitelist bluetooth device access., Bind to system search bar service, capture video output, send score networks broadcast, partial shutdown, run in factory test mode, Access download manager., change input device calibration, null, set time, access the cache filesystem, access notifications, manage network policy, Google Catalogs, capture audio output, discourage automatic device updates, directly install apps, permission to install a location provider, bind to a notification listener service, access DRM certificates, Control TalkBack
mannberg said:
I cant find the permissions needed in the zip. Can you post the output from
Code:
$ adb shell pm list permissions -s
Command to see what permissions is installed on the ADT-1
Click to expand...
Click to collapse
Ah, but there is com.android.mediadrm.signer.xml and com.google.widevine.software.drm.xml which reference /system/framework/com.android.mediadrm.signer.jar and /system/framework/com.google.widevine.software.drm.jar, respectively. So the DRM certificate referenced could be in there.
Really I guess a complete system dump would be most helpful, since we could continue to dig around where the files lead.
I'd say the DRM Certificates are in protected storage (ie. not really plain flash). Too bad.
Wow awesome work!Is this launch able to support any Android device like Ouya?
Thanks
Sent from my GT-N7100 using XDA Free mobile app
Grishka11 said:
So I was attending I/O and got the ADT-1, Android TV development device. These are the APKs I was able to pull from it (interesting ones).
Download links:
Android Media Shell a.k.a. Google Cast Receiver. Doesn't work for me even on the ADT-1 itself although reports successful service start in logcat.
Leanback Launcher, the launcher in Android TV.
Launcher L I don't know what this exactly is, but from its contents it appears to be something like GEL or Google Now but with TV UI. There is a bunch of activities and some strange tutorial slides inside.
Leanback Keyboard, a keyboard that can be operated with a d-pad.
Click to expand...
Click to collapse
Noob question but what does these apks do ?
I have an ADT-1 as well. Unfortunately they are locked up pretty good. Can't dump anything without root access. Boot loader is unlocked, so in theory you could boot an insecure kernel/recovery from fastboot, but you can't dump them to modify.
Downloaded all apks on my minix neo x7 running 4.2.2. Can confirm that Leanback launcher, Media shell and Launcher L cannot be installed on Jellybean.
Leanback Keyboard however, installed fine. I was able to set it as my default keyboard and move through the different characters with a dpad on a remote I have. Unfortunately I wasn't able to press any of them. The enter key on the remote I use didn't press any of the letters, but instead hit enter.
Soon this set top box is gonna receive a kit Kat update, so I'm crossing my fingers I can get any goodies from android TV working on it.
Here you got some other files:
https://www.dropbox.com/s/rlvrxijhmax2qio/Netflix_1.0_build91_(AndroidTV_ADT-1)-signed.zip
Some netflix libs and the netflix apk of the ADT-1. The apk is not the one that comes preloaded with the rom (which is around 0,5mb) but the update that netflix released in the play store.
I will try to find out if I can (I´m allowed) to share more files
Gtvhacker.com have made available a link to an OTA update the ADT-1 received. Don't know if it has the necessary DRM files included.
http://gtvhacker.com/index.php/ADT-1_Android_TV#Updates
Tested all these apks in my nexus 10 tablet. All installed fine except leanBack Launcher. It shows an error without description .
Also, I couldn't setup cast receiver. I tried with other devices and it seems to do nothing... How did you make it work?
Thanks!
tomas.comtom said:
Also, I couldn't setup cast receiver. I tried with other devices and it seems to do nothing... How do you make it work?
Click to expand...
Click to collapse
That's the $35 question.
So far, you can't.
Maybe it needs to be used with the apk in the play store
https://play.google.com/store/apps/details?id=com.google.android.apps.mediashell
Sent from my SM-N900T using XDA Premium 4 mobile app
It is the apk from the Play Store.

Categories

Resources