我想检查用户提供的电子邮件是否有效。那么如何向他的身份证发送确认链接?我有发送电子邮件的代码,但我想知道如何发送链接,点击后会打开一个网页。
String verify= "<a href=\"" + link + "\">" +"click this "+"</a>";
final sending m = new sending("adsadw@gmail.com", "password");
final Context con=this;
String[] toArr = {email};
m.setTo(toArr);
m.setFrom("007sanketh@gmail.com");
m.setSubject("Confirmation Link");
m.setBody("Please click on this " + verify + "to activate");
// Log.v("sanketh","here");
Thread t1=new Thread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
try {
// m.addAttachment("/sdcard/filelocation");
boolean a=m.send();
if(a) {
Toast.makeText(con, "Email was sent successfully.", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(con, "Email was not sent.", Toast.LENGTH_LONG).show();
}
} catch(Exception e) {
//Toast.makeText(MailApp.this, "There was a problem sending the email.", Toast.LENGTH_LONG).show();
Log.e("MailApp", "Could not send email", e);
}
}
});
t1.start();
这是我试过的代码。邮件工作正常,但我想发送一个链接作为确认链接。我该怎么做?
答案 0 :(得分:0)
要链接字符串中的链接,您可以使用:
String msg = "click here: email@example.com"
final SpannableString s = new SpannableString(msg);
Linkify.addLinks(s, Linkify.ALL);
你可以在上面找到一个好的阅读here。
答案 1 :(得分:0)
试试这个:
String confirmation_mail_link = "www.yoursitename.com"
String mail_body = "<a href=\"" + confirmation_mail_link + "\">" + Click + "</a>"
confirmation_mail_intent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(mail_body));
因此,它会将该文字“点击”转换为链接。
希望这有帮助。