Long Plaintext Email Links Not Displaying As Links - android

The plain text emails our company sends to clients who wish to receive them include a long string of parameters which are necessary for the business side. These are long strings including weird special characters and pipes and an email address.
The links, which are necessary for analytics and attributing sales, are therefore not fully clickable on iOS and Android, and so the parameters are not being properly logged... which potentially screws up a lot of things from analytics to attributing sales referrals.
On android devices these links fail by making the email address clickable.
On iOS devices some of the link is properly made into a clickable link., however the first part of the link is cut off at a certain number of characters, or perhaps because the string includes something that would cause it to believe it is no longer reading a hyperlink.
So:
A) Is there a character limit being applied to plaintext links in OSX, or a string combination that would cause the email to escape the text hyperlink?
B) Is there a simple way to include the email information. Some sort of escape char perhaps?
(HTML emails are the majority of what we do and we don't put a lot of effort into plaintext, because we think it drives very little sales. That is probably right... but when we're not actually tracking them it is not a scientifically sound assumption. And no doubt even a bit of bad data complicates the data analysts' jobs).
I would be interested if anybody can reference demographics on site visits from plaintext messages also... my personal guess is that if people are electing to receive emails in any kind, they are probably buying stuff. Who cares enough about data use to get plaintext emails only, but... opts into ones they don't want? In particular, because only one of the links properly tracks these users, I am guessing that their engagement is high to not be culled from the mailing lists altogether.

Since you have a logic in place, which is building your URL, you should check if your URL is correctly formed.
How to validate URL: https://stackoverflow.com/questions/1471201/how-to-validate-an-url-on-the-iphone
Once you confirm it's a valid URL, try shorten your URL using TinyUrl's API:
http://tinyurl.com/api-create.php?url=<#YOUR_URL#>

Related

Storing additional data to mail in IMAP

Introduction
I have a xy-problem
x: High level goal
I have dream: I want to store additional data to mails which are in IMAP. I the long run I want to be able to access this data via thunderbird and k9 (android app (mail use agent)).
Use cases:
I want to store a note in html format for this mail.
Upload a PDF file for this mail.
I want to store a re-submission date on the mail. Like google inbox snooze feature: Move the mail to a "do later" folder until the date is reached. (Evaluating this date and moving the mail to inbox again is not part of this question)
But I have no clue how to store additional data
y: My current thoughts about solving it
I need a way to identify a message in IMAP. I think the message id (without folder name) should work. I know that message IDs can have duplicates, but I see no other way. Please leave a comment, if you have a better idea.
Now I need a way to store this mapping somewhere:
`user#imapserver:message-id` --> `additional-data`
Question
How to store this mapping, so that thunderbird and k9 could access it?
Of course I know that thunderbird and k9 can't access this data today. How to patch them is a different question.
Background
I like free software and I like free communication. Up to now I use WhatsApp, Threema and other tools. But in the long run I want a free (like in software) solution. Email is wide spread, and I think it makes more sense to improve email than to create something new.
You could store annotations in a parallel mailbox as MIME messages using APPEND. You'd have to figure out a way to map annotations from one message to another.
So you can find the related message easily, you'll want it easy to search for. You could do something like using the message-id of the source message as the subject of the annotation message, or a transformation of the message id as the message id of the destination message.
Here are my thoughts on it... here is the current proposed and accepted standard for IMAP4 which is the current version...
https://www.rfc-editor.org/rfc/rfc3501
Here is a wiki link to show the previous versions and the progress that has been made over time ...
https://en.wikipedia.org/wiki/Internet_Message_Access_Protocol#IMAP4
I think the question is a good one, but maybe if your idea is good enough, contact the people that are in charge of the protocol and think about ways to potentially make IMAP5 with the kinds of functionality that you want to expand it to be able to utilize...
I would say that the best way would be to try making the IMAP protocol better. Read over all of the functionality that it currently supports and make suggestions to the group in charge of it. The additions that you are wanting to add sound great, but unless I misunderstood the question, I think that protocol updates might be the cleanest approach.
Sounds cool though.
Good luck... I hope you like my thoughts.
Have you considered Mailgun? It has an extensive API ( https://documentation.mailgun.com/api_reference.html#api-reference). Incoming messages can be stored, processed by your application and then sent via email. I believe you can add your own header field information (perhaps generating something like a GUID and using it for unique message tracking). Up to 10,000 emails/month are free (one of your preferences). If your application workflow and the API align, this might help get the job done.

Is there a way to pass a variable to an aspx file via the url?

I am trying to write a little Android app for my daughter. The goal is to scan a book's bar code and pass the ISBN number to this website: http://www.arbookfind.com/default.aspx . The result will show if the book is part of the Accelerated Reader program and how many points the book is worth. I am trying to automate the part where the ISBN would need to be entered into the search field.
For simplicity's sake, and because I'm not a programmer, I am using MIT's App Inventor 2. I can now scan and get the ISBN but I will need to know how to format a URL to the website that will allow me to pass the ISBN to it's search page.
Is it possible to send a variable via the URL similar to index.php?myvar=testing&someothervar=somethingelse ? I've tried but perhaps I am not using the correct variable name or format for aspx. Is there an easy way to see what the variable name is in the aspx displayed page in my browser?
EDIT To clarify, I am not trying to scrape data and avoid showing ads from the site I am using to generate the results. I am wanting to pass the ISBN number to the page and have it search and display the resulting page in the phone's browser. I am also fine with a method that would populate the search field and the user would have to hit the search button if that can be accomplished easier.
I would recommend abandoning this route, as it is highly unlikely that the owners of this website will want you passing a query string to their site anyway, but rather they will most likely point you to an Application Programming Interface (API) that they provide, so that your program can connect to this service (free or paid, depending upon the company) and then you can request the book's details by providing the ISBN in the request.
There is no discovery mechanism for an .aspx page like there is for a web service to find out the names of things to pass. Even if you figure out what the name of the query string is that you could pass in for ISBN, you run the risk of the implementation being changed and your "application breaking". While this is also true of web service APIs, since APIs are the route the website providers want you to use, as opposed to screenscraping, then they generally inform their users of breaking changes or newer versions of the API via documentation.
From what I can see that page does not accept URL-variables for their search field the way google.com and other does. The page is generated through some sort of content management system (CMS) and it relies heavily on javascript to make things work. I tried doing a normal search there, and you have two issues you need to wriggle around.
First, the page redirects you to a page where you select if your a student, parent etc. It seems that it relies on some session cookie to remember the setting, but it times out pretty fast.
Second, the form uses javascript to trigger the search, and it appears to be done using AJAX, a method of using javascript to trigger actions on the server and displaying the results, without actually loading the page again. You might be able to get a hold of the javascript code used and re-engineer it for your purposes, and call that using HTTP POST and/or GET from your app, but it is a tricky path, and quite possibly not allowed by the company since you will be loading data from their site, without presenting their advertisements and thus be costing them money.

Sending html email in android using <table>, etc. - is there really no relatively built-in Intent way?

I have read a good bit on the limitations of sending html email from android. All suggestions to send html email seem to be to just pass Html.fromHtml(yourHtmlString) to the intent as Intent.EXTRA_TEXT. This works for a few basic tags - bold, italic - but won't for anything like an html table.
It looks like you could try to extend some of the functionality of either Html or implement your own taghandler, but I am wondering if there is not a more fundamental limitation that will force you to do something completely different (like with the mail api or something).
The reason I suggest this is because, as far as the intent itself knows, Html.fromHtml(blah) is simply a charsequence, and if you call the methods on the charsequence interface on this object you don't see any html stuff (at least I didn't). All of the html/tag stuff seems to be wrapped up in the SpannableStringBuilder that Html.fromHtml actually returns... and I am wondering if the gmail app looks under the covers to see what the charsequence really is and then can handle a few tags, which means that there is no hope in doing anything on your app's side of things to get/trick the gmail app to handle anything more complicated than bold, italic, etc.
I have looked at the raw email the gmail app actually sends, and it automatically sends both a text/plain with no tags, and the text/html version with the limited number of tags. I even tried sticking in some escaped html tags that might ultimately get converted to actual tags in the text/html part of the email, but alas they stayed escaped... and that would of course be a bit hacky.
Anyway, for anyone who might have looked into this more, I wanted to do an additional confirmation that the default android "send html email" functionality will get you maddeningly close to what you might need, but in the end you've got to bite the bullet and implement a lot of lower level stuff yourself (such as Sending Email in Android using JavaMail API without using the default/built-in app , which means you've got to deal with the pw stuff, etc.).
Note (later):
I wrapped the SpannableStringBuilder returned from Html.fromHtml with a custom class that extended SpannableStringBuilder and passed that to the intent to listen for calls to the Spanned interface. It turns out that when things are written to the parcel that is sent to the email intent, TextUtils.writeToParcel does some special checking to root out the bold/italic stuff by first checking if the CharSequence is an instance of Spanned, and then asking for the spans (via spanned.getSpans). Nevertheless, I see no obvious hope in making the modifications to get something as simple as table/td tags handled in there. And I even tried modifying the toString() of my subclass of SpannableStringBuilder to return some raw table html to see what would happen, but it gets escaped somewhere else down there in the parcel-writing process.
And More (Later):
TextUtils.writeToParcel(CharSequence cs, Parcel p,...) will, if cs is an instance of "Spanned", write those spans only if they implement the "ParcelableSpan" interface... which is "A special kind of Parcelable for objects that will serve as text spans" and "can only be used by code in the framework; it is not intended for applications to implement their own Parcelable spans". So, even if you wanted to hook into this and write your own to handle table tags or whatever, it seems to be discouraged. Man I wish hackbod would weigh in here with something obvious I've missed.
This works for a few basic tags - bold, italic - but won't for anything like an html table.
That is a function of the email client, most likely. Not all email clients can author arbitrary HTML, on any platform. So, while Mozilla Thunderbird appears to let you create an HTML mail with a table, Gmail does not (leastways, I don't see an option for it in the message-compose window).
I am wondering if there is not a more fundamental limitation that will force you to do something completely different
Unless you write your own email client, extending the several classes needed to allow TextView and EditText to handle HTML tables (it's way more than just the Html class) will do you no good.
and I am wondering if the gmail app looks under the covers to see what the charsequence really is and then can handle a few tags
TextView and EditText can "handle a few tags", lining up roughly with what Html can parse/generate and SpannedString can represent.
None of that can handle an HTML table. Nor JavaScript. Nor CSS. Nor iframe or any number of other tags.
but in the end you've got to bite the bullet and implement a lot of lower level stuff yourself
I'd start by asking yourself whether sending HTML mail with tables from the phone directly is worth it. You could send HTML mail with tables from your server using a Web service interface, or you could send HTML mail sans tables from the phone. Neither of those would require you to collect "the pw stuff".

Safe user input

I have read many forum (and stack overflow) posts regarding escaping characters and sanitizing user input, but I'd like to tie it all together and make it a little more specific to the Android platform. Here's my circumstance:
I have an Android app that communicates with a web service via SOAP XML messages. Here's a sample XML message that might be sent (I'm leaving out the SOAP envelope around it):
<Log>
<Summary>user entered text</Summary>
<Details>user entered text</Details>
</Log>
As you can see, there are 2 places a user can input text in a form that is then inserted into this message to be sent to the web service. I need to:
A) make sure it's valid XML and
B) make sure it doesn't contain any malicious SQL content.
Are there any pre-included utilities in the Android API to escape invalid XML chars (such as &) that the user may have entered? (So that I can simply say "escapeXML(xmlstring);" or something like that)
Is there any way to check for malicious SQL (or other code injection) or should that be handled on the server-side?
As a side note: I'd almost prefer that the user was only able to enter A-z, 0-9 and basic punctuation (so as to avoid weird unicode characters that can't even be seen or interpreted sometimes). Is there a good way to restrict user input to a subset of characters?
I know this is a couple questions built into one, so if you only know part of it, please provide an answer anyways and I will be more than happy to upvote or accept it. Thanks in advance for all the help! (StackOverflow is where I come when I've consumed way too many forum threads and have gotten myself all twisted around about what is appropriate in my circumstance)
The best way to deal with SQL Injection is using parameterized queries. This is done on the server side. Everything else is secondary, unnecessary or barely scratches the surface of the issue.
You should read these:
Safe DateTime in a T-SQL INSERT statement
problem in inserting the value in the database
http://www.codinghorror.com/blog/2005/04/give-me-parameterized-sql-or-give-me-death.html
On Jeff Atwood's blog, I like where he says:
Non-parameterized SQL is the GoTo statement of database programming.

Adding links to an email message

I was wondering if it is possible to hook into the gmail and email
applications and check to see if it contains text that matches a
regular expression, and if it does, make that text into a link with a
URI that would open my application. What i am thinking of is similar
to how the gmail application can detect a web address or phone number
and make it a link. Is something like this possible?
The Gmail app is closed source and you only have the hooks they give you. AFAIK regular-expression-to-hyperlink-conversion isn't one of them:
Extending Android's Default Gmail/Email Applications
Depending on what you're doing, you might be able to send mail through some kind of gateway which does this work on the message prior to delivery. So rather than emailing johndoe#gmail.com people could write to johndoe#example.com, and the work of translating phrases into URIs could be done at example.com then forwarded to gmail.com with links in place...
But people are link-savvy these days. You can make links plenty readable, for instance look at http://en.wikipedia.org/wiki/URL ...fairly obvious, no magic required and I can enter that even without Google's help.

Categories

Resources