How to email bold text from android application? - android

I am using this code for mailing from android application.
GmailSender sender = new GmailSender("android.tech1q2#gmail.com","password");
sender.sendMail("Thank you state",
"<u>Jignesh</u><b>Jignesh</b>",
"android.tech1q2#gmail.com",
"jansodariya#gmail.com");
but I am not getting words underline and bold then what should I do for this please help me
I want to send mail as Html.
Thanks!

try this
sender.sendMail("Thank you state"
,Html.fromHtml("<u>Jignesh</u><b>Jignesh</b>"),
"android.tech1q2#gmail.com"
"jansodariya#gmail.com"));

Related

How to localize numbers in a GCM/FCM notification message?

When sending a push notification through GCM (switching to FCM soon) to an Android device, how can I localize numbers that appear in the message title/body based on the language of the phone?
Example Message:
John Doe 137
If the device language is set to Arabic the numbers should localize
Localized Message
John Doe ١٣٧
Since I don't know the users device language when sending the notification, how can I localize the number when the message is received? The onMessageReceived callback does not execute unless the application is running in the foreground, so I can not perform a string replacement on the numbers there.
For context Below is an example of the gcmNotification JSON I'm sending to GCM from my services which is taking advantage of some of the other localization params the payload allows you to use.
"gcmNotification": {
"title_loc_key": "some_title_key",
"title_loc_args": "[\"john\", \"Doe\", 137]",
"icon": "TheIcon",
"body_loc_key": "some_key",
"sound": "somesound",
"color": "Blue",
"collapse_key": "somekey",
}
In general you don't try. Arabic numerals (the normal 0-9) are well understood. If you want to insist on trying, you can do it client side with a string replace. Or server side by posting your locale to it and letting the server translate before sending down.
To solve the issue, I ended up creating just a helper class with a method to handle the conversion. I run the message text through it and it returns the translated values. It has worked well for me so far.
public static class NumberHelper
{
public static string ConvertToArabicNumbers(this string input)
{
return input.Replace('0', '\u0660')
.Replace('1', '\u0661')
.Replace('2', '\u0662')
.Replace('3', '\u0663')
.Replace('4', '\u0664')
.Replace('5', '\u0665')
.Replace('6', '\u0666')
.Replace('7', '\u0667')
.Replace('8', '\u0668')
.Replace('9', '\u0669')
.Replace('.', '\u066B');
}
}

Reply to SMS in VBS

My question for you today is "How to reply to an email using windows vbscript." (Gmail) That may not be the best explanation...
WAIT, I already know how to SEND an email (to my phone through phonenumber#txt.att.net) using VBScript, but I want to reply to a text. I have a system that alerts my phone when an action is performed on my computer (through VBScript) but this keeps happening. It's as if I receive the message from a different address each and every time.
So, is there any way to make it so I receive the text from the same recipient each time? Currently, the "phone" number of the sender started at 1410200500 and counts up every time I send it using this vbs code.
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "myemail#gmail.com"
oMsg.To = "myphonenumber#txt.att.net"
oMsg.TextBody = "ALERTMSG"
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp.gmail.com"
oConf.Fields(schema & "smtpserverport") = 465
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic
oConf.Fields(schema & "smtpusessl") = True
oConf.Fields(schema & "sendusername") = "myemail#gmail.com"
oConf.Fields(schema & "sendpassword") = "supersecretpassword"
oConf.Fields.Update
oMsg.Send
Everything works except for the issue of the sender being different each time.
Please help
Edit: I have found that this is unavoidable, thanks to everyone that helped!
There is nothing wrong with your VBScript or the CDO configuration.
The value assigned to the Sender by the SMS Middleware that takes the e-mail and forwards it to an SMS service is outside your control. The only option you have is to contact your SMS provider but I wouldn't suggest they will change how this works.
In fact in this Video at 0:40 it states;
"the number that appears on your recipients phone or device may not be your actual phone number, but they will see the name, subject and e-mail address you used to send the text message."
Useful Links
Send email as text message (AT&T Support)

How to display properly formatted E-mail in TextView in android

I am working on an E-mail Application where I have to send and receive and also have to display email in TextView when ever user wants to read it
This is the feed I am getting from API :-
{
"messages":
[{"id":"136902",
"from":"Akash",
"email":"akash#email.com",
"subject":"mail App!!",
"message":"Hi Devraj,\n\n \n\nKindly provide sabmail apk for google play store.\n\n \n\nRegards,\n\nAkash",
"date":"1448870780",
"userid":"75",
"recipients":"devraj#mail.com ",
"status":"0",
"isread":"1",
"priority":"3",
"size":"3057"}
]}
I am taking the "message" tag and displaying it in TextView. It looks like this
Hi Devraj,Kindly provide mail apk for google play store.Regards,Akash,
But, I want it to be look like this,
Hi Devraj,
Kindly provide mail apk for google play store.
Regards,
Akash,
How can I do achieve this.
This is the way I am setting it in TextView
String msg = messageDisc.getMessage();
Spanned sp = Html.fromHtml(msg);
emailText.setText(sp);
emailText.setMovementMethod(LinkMovementMethod.getInstance());
Please let me know what mistake I am doing here.
Try to replace: \n with <br>.
String msg = messageDisc.getMessage();
msg = msg.replace("\n", "<br>");
Spanned sp = Html.fromHtml(msg);
Supply android:maxLines="<any number>" to the TextView. So that \n will work.
first parse the json data and stored it into a different String.
Then set the String object to the edittext by seperating it with a \n line.
eg: emailText.setText(sp+"" +\n+""+obj);

XMPP jid-malformed(400) error Android while creating user

I am trying to develop XMPP chat in Android and while creating new user using AccountManager I am having the following exception :
jid-malformed(400)
My user-connection code goes like this:
AccountManager manager = connection.getAccountManager();
try {
manager.createAccount(username, password);
}
catch(XMPPException e){
e..printStackTrace();
}
here my
username = abc#xyz.com
password = 12345678
I learned that we need not require to send service name with the username from post
But in my username the format says that my user is "abc" and my service is "xyz.com"
what should I do to keep '#' in my username?
Thank You. :)
JID escaping is done as per XEP-0106. Specifically, the "#" character should be replaced by "\40" to keep the "#" as part of the JID.

Phonegap activityStart in android not showing the messge which I pass

In my project I used navigator.notification.activitystart("Title","Message").
But it is just showing the title as "Busy" and message as "Please wait". I can stop the activity with navigator.notification.activityStop()
So i want to ask does the activityStart really shows the title and message on android phones.
I am using phonegap1.1.0
Thanks all in advance
From both phonegap-1.1.0.js and phonegap-1.3.0.js:
Notification.prototype.activityStart = function() {
PhoneGap.exec(null, null, "Notification", "activityStart", ["Busy","Please wait..."]);
};
Note that activityStart takes no parameters, so you'd have to modify it to actually accept your parameters.

Categories

Resources