Email file attachment

I am sending an email by attaching a file with an email address in the following code. I can not get the correct email address in my inbox in the return

Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_EMAIL, emailAddressList); intent.putExtra(Intent.EXTRA_SUBJECT, emailSubject); intent.putExtra(Intent.EXTRA_TEXT, emailText); intent.putExtra(Intent.EXTRA_TEXT, emailText); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("android.resource://"+ getPackageName() + "/" + R.drawable.pic)); Log.v(getClass().getSimpleName(), "sPhotoUri=" + Uri.parse("android.resource://"+ getPackageName() + "/" + R.drawable.pic)); startActivity(Intent.createChooser(intent, "Choice App to send email:")); 

In the inbox, the result will be the same as the image.

    H    !1AQaq " 2  B#  Rb3 r  CS$ c    %!1AQq"2aB#  ?  T@    pJ =>       ` pH ` A00V  7LM      H    ]w v  峆     9N! *y   k   _ {b p[y8 ~Leަݍ> ˢm    #  1 һ.W w \  oj   7 8 # s V U  j Q   m ִ0  ~*S2 :V6  Oۋ&|Dj h  +U xy. Q Bʏ; M ʙ  b   Ɇ`v v* tgT  oX Cf   )[  Io!F v ޵  {cT269 ݮ v6X8        *S  @   A   H$s @   @   -?b      i@  P8iA H5 AH  h3B   W   Km :  EFcԗ  ߦ x  ϣ  b, $ H`   j x} m<1   u Z; ,       G ?  *Q췮%  ޷ /SLϠu   x  c^ #  ? lP T mK|      h / Lp4 T4;͝MWI\ a'   Zӥ  y ۝ 7MV FZ E #5  g  y OL      .׉ Os3  h n  d   @   A   H$2A  I   M I  th@  (j  > H AU   c  _A     xG  #asY B  > =I  n3  ù 9҉F,yq A  x  /  c   zڶ鄛  0` ~Q^     s:"m- 8   8&   o    \XH a9    -  n<  X Y } YD D   N V  ne Ѽ  5  ;74 H VRƫś       k@p    w% ~Z O 9l ^[     8w ŏU{Ei   t DP   y>G8. <  m VSP  v   C$   ``  @   BQ  @  z   $ P  5    i A? = R\<˿ [ ^n[, Pz H_j"դ   cZMr!y H s  }   Dz[_߷ָlaϋ H  { Y S o 4; -  haqk^d  :F,  [ 3  {t^  j X  n& n  <  9 s_  k;LV ,       d   D  L ]p   s  T  + e = 6   m.?( #Igh YZ   A    W8< c "  ]$f m  m  y  H=٭ +X ȑ΍  Q  |    X    v  6  :     ~  O   h  HD    @ @   s   $ @  TA 0A&   =*@   J   H4 p; e ]  ;h 3  iq  5 =    Π   ]r ] \ \+ /     y    絊[s`m( ff\f \+ z  &p5 * 0      !r Y^  m<  :On f 4׿     H] X   n } -  2i     ;l- y 4 R q=  >  0u &k    U  ^j  &̦  Q {;e /   > e}g ?-  A w Z 6^    \ ^ ܖ     [ -\* њ  onR0=1   ܽ gl [ ; w   j Q  ښX  ]   ]. ǥ%y G?* ;   0 p A H$  A HI  BA* p*  $   @   $  pgMo&     Vw  ӌ s ` ?| ݳ m_{p- t % PjI" .k     nv   ŀ   㻱    70 p    p yiV    ~bGeW     ;  Ѵ7 r   mY ( , 9 B^N  $Q  *Us  }Ǩ  \ .q36"<´dzO  ٜ:  ! ѱ T  X  1 S   :i  N     K?   S7p Ml  };0 I ߧ?g  +  r  b9   ?N{ -;)    >w K l   | R$$LH    s     H @ b a A* z pH @ pJ $oT   9W  7 ,    O úg o  d     Kv  N1 8s^g[    {     h k*94  \V ^g  )w    nG;  h(   ./    m z    nd  դ{ Z;   \^  #do E<ˮ F    Q    y!   R㨑S   ^z[O  k< ;x#     T ' }   v  sV  ' t     A      A0L  A 8$  @ AQ  : e    K 9 ` gF } m<5  k  : ƿj    oc  5  x/     :  Po  M ߶  HY_[lp |℁ c F җ ^ٹ q,>f  -s{9k8yw d   i aZØBd    k67*  R}  ̚ na ņF n` J  k[ T1] 8 d  IF \3 WI u  2  ,"    u  g    侞  a  7"     8A   I     B        &* mA H({PHD     5ι 4y @ T  R = T YY Vɢ!  l   xz     >hΖD    9 s [  E m  G   dn9 !#  \ӊ S   nYQB|   U 眵 hxp9  ܡ 5I%Z< : ZV ,o՘ڢ y$ y`f       y> O .*   @   tt$?A x  $3A.  &   `  A  ` rD67  ~$ e88     N j   d  2n    Iu  Q pTiۗ   ?  w#k  0 0      ԭ  b퇡   m q   W !  x Uࡌ   VH M   DM2 !.{  *\]  R =<   $vM  y   [ 0< d6 |WM$ P H  I 4 7}    F 3 Z      l  V4>  $ %L m  n    q Q r - h b } RȾ  d.=  >         ×w   =H p   8@   8@    *      A6     & P)f      f Y 1   Hh 1  U q^  QXApa魏 !f   0\0   i    ~  ͹ 0  P >   ] +  I o yy k I kZ; + x ٜRN   C     c~   p Ճ  d 0ET'49   q%Ē~*d;p  }ȣv }I p o =   ̑    ƺ */  _KY z |  \ӭ   > n    ޷  hd   2   ur|[ Ot w   3    j   9  Ci b߻ 0dDMk0  f  L # 6u 3 {, ۫  W  ? |       v  p  @ @    |  m(,  AI    7$ F : \ bjJ0  M ?b fs:kn        f J4-   B b     t   -   , tT+8 8 S# ۗ yv j ;     =ؒ   aE    8y   n. P asw     ' ykB b     o  i NV2N| n s BEZ U    y ᱚ  ܹm .   w:;c ]  o ͹ N m $3> zC(  sEX  
+1
source share
2 answers

Try it -

 final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{"email"}); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "subject"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,"Test"); //has to be an ArrayList ArrayList<Uri> uris = new ArrayList<Uri>(); //convert from paths to Android friendly Parcelable Uri's for (String file : filePaths) { File fileIn = new File(file); Uri u = Uri.fromFile(fileIn); uris.add(u); } emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); context.startActivity(emailIntent); 

And also just write the previous question fooobar.com/questions/365107 / ... about attaching images in an email through intent.

+3
source

it works

  File imgFile = new File(picturePath); Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto: ???@gmail.com ")); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "subject"); emailIntent.putExtra(Intent.EXTRA_TEXT, "body"); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(imgFile)); startActivity(emailIntent); 

picturePath coud be "/storage/sdcard0/DCIM/Camera/yourpic.jpg"

+4
source

Source: https://habr.com/ru/post/916256/


All Articles