Discussion:
problem sending an email with an attachment programmatically
mudit
2009-08-07 13:25:17 UTC
Permalink
hello..

i`m trying to send an email using native email client on android
phone.

I have tried following ways to add an attachment to the mail...

method--1
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://sdcard/
abc.jpg"));

method 2

Sending the image as body content---

sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"alt = \"pleaseview this
image\"/></b></BODY></HTML>");


i can successfully attach the image manually but when i tried to
attach and send it programmatically the mail was sent without
attachement.

Please let me know if there is a way to send an attachment
programmatically by using email client
Fin
2009-08-13 13:14:39 UTC
Permalink
Post by mudit
hello..
i`m trying tosendan email using native email client on android
phone.
I have tried following ways to add anattachmentto the mail...
method--1
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM,  Uri.parse("file://sdcard/
abc.jpg"));
method 2
Sending the image as body content---
sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"alt = \"pleaseview this
image\"/></b></BODY></HTML>");
i can successfully attach the image manually but when i tried to
attach andsendit programmatically the mail was sent without
attachement.
Please let me know if there is a way tosendanattachment
programmatically by using email client
I am having the same problem,
using the putExtra(Intent.EXTRA_STREAM) appears to work when I see the
email message in draft mode. I can remove it or send but the email
does not include the image attachment. I have read that this may be a
bug which is resolved with a reboot but I have tried both a reboot of
the machine and phone I am debugging on along with multiple re-
releases. I can confirm the attachment file exists on the sdcard and
am not recieving any noticable errors from adb logcat.

Anyone managed to find a usable solution to this?

Regards,

Fin
Sławek
2009-10-03 20:23:46 UTC
Permalink
hi, mudit try to use
file:///sdcard/abc.jpg
instead of
file://sdcard/abc.jpg
Post by Fin
Post by mudit
hello..
i`m trying tosendan email using native email client on android
phone.
I have tried following ways to add anattachmentto the mail...
method--1
Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM,  Uri.parse("file://sdcard/
abc.jpg"));
method 2
Sending the image as body content---
sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"alt = \"pleaseview this
image\"/></b></BODY></HTML>");
i can successfully attach the image manually but when i tried to
attach andsendit programmatically the mail was sent without
attachement.
Please let me know if there is a way tosendanattachment
programmatically by using email client
I am having the same problem,
using the putExtra(Intent.EXTRA_STREAM) appears to work when I see the
email message in draft mode.  I can remove it or send but the email
does not include the image attachment.  I have read that this may be a
bug which is resolved with a reboot but I have tried both a reboot of
the machine and phone I am debugging on along with multiple re-
releases.  I can confirm the attachment file exists on the sdcard and
am not recieving any noticable errors from adb logcat.
Anyone managed to find a usable solution to this?
Regards,
Fin
Jason
2009-11-18 15:31:06 UTC
Permalink
I am also having this attachment issue with the Email application. It
works perfectly fine with the GMail app, which throwing me for a
loop. My code is as follows:

Intent sendIntent = new Intent(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile
(attachmentFile));
startActivity(Intent.createChooser(sendIntent, "MailSender"));

Any ideas as to what's going on?
Post by Sławek
hi, mudit try to use
file:///sdcard/abc.jpg
instead of
file://sdcard/abc.jpg
Post by Fin
Post by mudit
hello..
i`m trying tosendanemailusing nativeemailclient on android
phone.
I have tried following ways to add anattachmentto the mail...
method--1
IntentsendIntent = newIntent(Intent.ACTION_SEND);
sendIntent.setType("image/jpeg");
sendIntent.putExtra(Intent.EXTRA_STREAM,  Uri.parse("file://sdcard/
abc.jpg"));
method 2
Sending the image as body content---
sendIntent.putExtra(Intent.EXTRA_TEXT, "<HTML><BODY><b><IMG SRC=
\"data:image/jpeg;base64," + <imagepath> + "\"alt = \"pleaseview this
image\"/></b></BODY></HTML>");
i can successfully attach the image manually but when i tried to
attach andsendit programmatically the mail was sent without
attachement.
Please let me know if there is a way tosendanattachment
programmatically by usingemailclient
I am having the same problem,
using the putExtra(Intent.EXTRA_STREAM) appears to work when I see the
emailmessage in draft mode.  I can remove it or send but theemail
does not include the imageattachment.  I have read that this may be a
bug which is resolved with a reboot but I have tried both a reboot of
the machine and phone I am debugging on along with multiple re-
releases.  I can confirm theattachmentfile exists on the sdcard and
am not recieving any noticable errors from adb logcat.
Anyone managed to find a usable solution to this?
Regards,
Fin
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
jasper
2009-12-08 17:21:47 UTC
Permalink
I'm trying to embed an HTML reference to an image to include in an
HTML email.

I used a SpannableString to successfully create an email that has a
http href in it, as shown below.

But I have not been able to add an image into the body of the email.
Other programs add something like this directly to the body of the
email:

<img src="http://thumbs1.ebaystatic.com/pict/
1804380093048080_1.jpg">

This doesn't work for me - the text is a hot link. I've tried various
permutations of using SpannableString but can't get the image to
appear.

Any tips for this would be muchly appreciated.


Here's the body of an email message I've successfully created:

<p>Check out this item I found on eBay:</p>
<p><a href="http://cgi.ebay.com/DEALS-cps-QA-bid-test-do-not-bid-4-
BID-
BIN_W0QQitemZ250528416791QQcategoryZ30120QQcmdZViewItem">DEALS cps QA
bid test do not bid 4 BID + BIN</a></p>


Here's the code that successfully creates the above email message:

String email_subject = getResources().getString
(R.string.default_share_subject).trim();

final Intent i = new Intent(Intent.ACTION_SEND);
i.setType("message/rfc822");
i.putExtra(Intent.EXTRA_SUBJECT, email_subject);

SpannableString item = new SpannableString
(mFoundItem.getTitle().Value(""));
item.setSpan(new URLSpan(mFoundItem.GetItemUrl().Value
("")), 0, item.length(),
Spanned.SPAN_INCLUSIVE_EXCLUSIVE);

SpannableStringBuilder email_body =
new SpannableStringBuilder(getResources().getString
(R.string.default_share_text) + "\n\n");
email_body.append(item);

i.putExtra(Intent.EXTRA_TEXT, email_body);

startActivity(Intent.createChooser(i, getResources
().getString(R.string.share_chooser)));
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-***@googlegroups.com
To unsubscribe from this group, send email to
android-developers+***@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
Continue reading on narkive:
Loading...