send mail from contact us page to the specific emailid
我已经尝试过...但是当我提交表单时,它进入了撰写邮件...我只想通过单击提交按钮来发送邮件...请帮助我...
1 2 3 4 5 6 | Intent mailintent = new Intent(android.content.Intent.ACTION_SEND); mailintent.setType("text/plain"); mailintent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] {"[email protected]" ,"[email protected]"}); mailintent.putExtra(android.content.Intent.EXTRA_SUBJECT,"info..."); startActivity(mailintent); |
和
1 | <uses-permission android:name="android.permission.INTERNET" /> |
在清单文件中。
我认为您正在尝试以编程方式发送电子邮件,而没有打开Email Composer。
如果是这样,您可以检查此链接
希望这可以帮助
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | package com.contact; import java.util.regex.Pattern; import android.app.Activity; import android.app.Dialog; import android.os.Bundle; import android.content.Intent; import android.graphics.drawable.AnimationDrawable; import android.view.View; import android.widget.Button; import android.widget.EditText; import android.widget.ImageView; public class ContactusActivity extends Activity { // Initializing variables EditText inputName; EditText inputEmail; EditText inputphone; EditText inputcomment; ImageView iv; public final Pattern EMAIL_ADDRESS_PATTERN = Pattern.compile( "[a-zA-Z0-9+._%-+]{1,256}" + "@" + "[a-zA-Z0-9][a-zA-Z0-9-]{0,64}" + "(" + "." + "[a-zA-Z0-9][a-zA-Z0-9-]{0,25}" + ")+" ); String regexStr ="^[0-9]$"; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); inputName = (EditText) findViewById(R.id.name); inputEmail = (EditText) findViewById(R.id.email); inputphone = (EditText) findViewById(R.id.phone); inputcomment = (EditText) findViewById(R.id.comment); Button sendmail = (Button) findViewById(R.id.sendmail); final ImageView iv= (ImageView) findViewById(R.id.test_image); iv.setBackgroundResource(R.animator.animation); sendmail.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { String strname=inputName.getText().toString(); String strmail=inputEmail.getText().toString(); String strphone=inputphone.getText().toString(); String strcmnt=inputcomment.getText().toString(); if(strname.length() == 0 || strmail.length() == 0 || strphone.length() == 0 || strcmnt.length() == 0 ) { Dialog d=new Dialog(ContactusActivity.this); d.setContentView(R.layout.dialog); d.setTitle(""); d.show(); //Toast toast=Toast.makeText(ContactusActivity.this,"please fill all the details.....", 7000); //toast.setGravity(Gravity.CENTER,0,0); // toast.show(); } else if(strcmnt.length() <=20) { Dialog d=new Dialog(ContactusActivity.this); d.setContentView(R.layout.comment); d.setTitle(""); d.show(); } else if(strname.length() <=3) { Dialog d=new Dialog(ContactusActivity.this); d.setContentView(R.layout.name); d.setTitle(""); d.show(); } else if(strphone.length() <10 || strphone.length() >10) { Dialog d=new Dialog(ContactusActivity.this); d.setContentView(R.layout.phone); d.setTitle(""); d.show(); } else{ if(checkEmail(strmail)){ String result=strname +"\ "+ strmail+"\ " + strphone+"\ " + strcmnt; Intent mailintent = new Intent(android.content.Intent.ACTION_SEND); mailintent.setType("text/plain"); mailintent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[] {"[email protected]" ,"[email protected]"}); mailintent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Please collect my info..."); mailintent.putExtra(android.content.Intent.EXTRA_TEXT, result ); startActivity(Intent.createChooser(mailintent,"Sending mail...")); inputName.setText(""); inputEmail.setText(""); inputphone.setText(""); inputcomment.setText(""); } else { Dialog d=new Dialog(ContactusActivity.this); d.setContentView(R.layout.email); d.setTitle(""); d.show(); } } } }); // iv.setOnClickListener(new OnClickListener(){ // public void onClick(View v) { AnimationDrawable anim= (AnimationDrawable) iv.getBackground(); anim. start(); } // }); // } private boolean checkEmail(String strmail) { return EMAIL_ADDRESS_PATTERN.matcher(strmail).matches(); } } |