Display NSString as HTML text - show string as a link - iphone

I have a string wherein there may a phone number, mail address, web address, an email address or it may be some plain text. For example: my phone number is 8009000300.
Firstly, how to display this string as HTML text?
Secondly, if displayed as HTML text, will/can 8009000300 (or web address or mail address or email address) be displayed as a link? I am going for this approach as NIAttributedLabel didn't work for me.
Note: Phone number (or other special strings) may be there in between the complete string or at the start/end of string.

You can use UITextView for displaying text and set the dataDetectorTypes property to UIDataDetectorTypeLink,UIDataDetectorTypePhoneNumber according to your requirement.

You can use CoreText, or try OHAttributedLabel or TTTAttributedLabel.

Related

How to extract the email from email body using applescript?

I want to get the email address that i mention in the image.The email i received from my clients and i am using applescripting and
i want to use that email as recipient.I will send auto mail to this email address.
Thank You.
The concrete solution depends strongly on the HTML text.
You got two options:
Get the source of the message, extract the HTML part, use an HTML parser to get the address or convert the HTML text to plain text with textutil.
Get the content of the message – which is plain text – check all paragraphs for email parts and use regex or sed or text item delimiters to extract the address.

How to set email format plain text using mailto function

i am read a email using Web-methods services and facing problem, Web-methods reading HTML format email as a plain text and giving us HTML. so, i like to set content type as plain text through mail-to function. and i am using this syntax but not working:
mailto:xxxxxxx#sapient.com?Content-type=text/plain"
problem solved, solution: we can add a property on exchange server for particular email id that this email id will get email in text/plain form only. so now i am sending a HTML email then exchange server convert it as a plain text email.

Default Phone Number for Texting in ABPerson

I am trying to get the default phone number for sending a text message for an iPhone Address Book contact using ABPerson. I understand that ABMultiValue is to be used. But I cannot find out if there is a way to determine the default text message phone number (or for that manner, the default phone call phone number, email or address). I am about to grab the first object for each, but I am concerned that, for a text message, the phone may be a land line or otherwise unable to receive texts. Any advice on how to approach this matter would be appreciated.
You can extract specific values for home, work and cell phone number from the ABMultiValue. You will probably want to use the value corresponding to kABPersonPhoneMobileLabel and/or kABPersonPhoneIPhoneLabel to send a text message. If neither of those values exist, choose the first available phone number.

How to pass long URL in plain text emails?

I have this account creation email that is sent out to anyone who is trying to create an account as I need to authenticate that they are who they say they are.
However, my issue here is that the URL where they need to click when they receive my email is too long and some email clients do not handle that very well and sometimes truncates the URL thus making the URL invalid when clicked.
Because the URL contains the domain name, the hashed email and a long activation code. It looks something like this.
http://domain.com/activation?email=75a5867d3df134bededbaf24ff17624d&key=8fecb20817b3847419bb3de39a609afe
While some email clients are ok with this but some are not...And I don't want to use HTML email and rather stick with plain/text email. Also I heard horrible stories using URL shorteners so I am not sure if I should use them...
Any insights in this area is appreciated!
I would definitely agree with Jason: shorten your url.
Think of what you really need.
Most likely the email address is in the database already, so you can refer to if with a short ID (let's say 7 numbers max). Your signature can be something very simple as substring (base64_url(md5(email+salt)), 0, 5). 5 base64 characters are 64^5=about 1 billion possibilities. This is probably secure enough (and what would the real damage be if someone registered with a wrong email address). So your url would be http://domain.com/activation?email=1234&key=aD5Y_, http://domain.com/activation?e=1234&k=aD5Y_ or even http://domain.com/activation?e=1234aD5Y_ . In the last format you know the last 5 characters are the key, so the rest is the id. Note that the code example assumes md5 to return in an 8-bit string format (and not hex string format), and base64_url uses a url safe base64 method. Also, some background info on a salt.
If your email address has a long id or needs to be encoded in the url as well, or the above is not short enough yet, consider an even shorter form. Basically this will result in making your own url shortener. Just before you insert the link into the email, generate some random 5 character string. Insert this string as key into memcached (or the database), with as value the original url. Then your url could be http://domain.com/redirect?key=rT-tW . When you see this in your app, just retrieve the original url from the database/memcached and redirect there.
Do make sure that your system is robust against the following:
Someone enters an email address (their real email), you send the link
That person changes their email address into something fake on the website before clicking the link, you send a new email to the new (fake) email address
They now click the link from the first email and your website confirms their email address in the second (fake) form.
One way to do this is make sure to use the email address itself (and not for instance just the user id) in the key generation, as suggested above.

How to get email address from MFMailComposeViewController

Application is sending email by using MFMailComposeViewController, everything works just fine. However after sending email, the recipient address needs to be stored for further processing. As far as I can tell, there is no API for this.
How do I get the email address where message was sent to?
Should I subclass MFMailComposeViewController and override something? What would that be?
Could I find email address by looking at MFMailComposeViewController view hierarchy? What would I be looking for there?
Any other ideas?
Figured out a partial answer, here's the details:
http://jomnius.blogspot.com/2011/02/how-to-find-mfmailcomposeviewcontroller.html
Problems: it finds the recipient email address(es), but only if that fits in about 35 character text string. Otherwise you find only a summary string like "aaa#aaa.aa & 2 more...". So where are the actual email addresses in this case?
As an alternate UI flow -- though obviously I don't know your app, so only you'll know whether this can work -- you could instead have the user enter recipient info into a textfield and then push the mail composition viewcontroller (with the recipient(s) pre-filled).
You could even use a variation of Joe Michel's Multi-Recipient Picker library to make it feel more like the native recipient selection.