How do you take a picture and send it to gmail Android client as attachment?

Hi,
I know I could use sharing component. But I would like to have a prefilled subject an TO: field.

My goal is simply:

  • take a photo;
  • and then automatically send it to gmail android client, to have subject and TO prefilled, and to have that photo as attachment.

I wouldn't want to use php, and I wouldn't want to enter any SMTP or other e-mail server parameters.
I would like the end user to have the email pre-filled and then have him/her send it from his client.

How can this be done?

Thank you

Perhaps this is part of what you need to do

1 Like

Yes, but it is very similar to the standard share extension.
In example how to have prefilled TO: address?

Thank you

Taifun

@Taifun thank you. This is the link I see in a lot of messages, and before I wrote here a little bit I looked at it, but it doesn't seem to me that there is among that list of titles, the one that allows me to reach my goals:

  • Have a button that makes me take a photo
  • that shares it with gmail
  • show me a pre-filled gmail message with TO, subject, and attached image
  • let me just click to send the email, using the gmail button

Did you try the example?

For address, use the address slot should prefill.

Use TextBoxes at the green arrows to prefill subject and message.

What is the example I could try? Is there an example from which I can see that I can set address?
I'm sorry but I didn't understand.

Thank you again

Only to understand you: is this the example?

1 Like

Use a button component together with the camera comoonent

Use one of the solutions mentioned in my previous link, for example my mail extension, which offers adding attachments App Inventor Extensions: Mail | Pura Vida Apps

Use some label or textbox components

Use another button component

A very good way to learn App Inventor is to read the free Inventor's Manual here in the AI2 free online eBook App Inventor 2 Book: Create Your Own Android Apps ... the links are at the bottom of the Web page. The book 'teaches' users how to program with AI2 blocks.
There is a free programming course here Course In A Box and the aia files for the projects in the book are here: App Inventor 2 Book: Create Your Own Android Apps
How to do a lot of basic things with App Inventor are described here: How do you...? .

Also do the tutorials http://appinventor.mit.edu.ezproxy.canberra.edu.au/explore/ai2/tutorials.html to learn the basics of App Inventor, then try something and follow the Top 5 Tips: How to learn App Inventor

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

Yes, tim's example How do you take a picture and send it to gmail Android client as attachment? - #6 by SteveJG

1 Like

Thank you @SteveJG , I didn't realize.

I have built this

But I have this error and gmail does not start. What am I doing wrong?

Thank yoi

Are you using these Blocks too?

If you run Tim's example, does it work with a stored png or jpg image?

Possibly you cannot use the SendMailAttach block in the AfterPicture Block immediately?

1 Like

I have modified my blocks. I have the gmail message that I cand send, but without the attachment.

It's my fault, I have to figure out how to pass the path of the temporary image just taken

  1. You are expecting to get the afterActivity AFTER you start the Activity, but you try to build the email at the same time! Look at my blocks again. You need to get your process workflow in the correct order:
  • Take Photo
    then
    *Copy the photo taken from your ASD to shared storage (Downloads or Pictures for example)
    then
  • Get Photo file path from Shared Storage (you could use Activity starter pick/get content here) and set to a label/variable
    then
  • use the extension blocks to build the email, using the above label.text / variable value for the file path

The activity starter blocks in @TIMAI2 's example pick an image from shared storage... however your image is stored in ASD amd the activity starter can't pick from there. .

Also as far as I can see @TIMAI2 's extension is not able to send attachments from ASD... @TIMAI2 is this correct?

If you want to use @TIMAI2 's extension then you should copy your image to shared storage and attach it from there

Taifun

Good spot Taifun :wink:

The file in question for the attachment will need to be from Shared Storage otherwise GMail will not be able to find it (and as Taifun says, could not be picked from the ASD using the ActivityStarter in any case)

I have edited my post above top reflect this for others passing here

Hmmm, in testing I cannot get it to attach a file now.....

Got it working, GMail needs a contenturi !

Blocks to follow

There may be an extension that converts a file path to a contenturi, so that you can automate the image file selection.

1 Like

First of all thank you very much @TIMAI2 !!!

And then I'm kind of glad to see that it's not such a simple thing.
However, I need to find a way not to have the photo selected, but to send the one taken directly.
But don't waste any more of your time.

Thank you very much

well... it can be simple... Here are the blocks using my mail extension
only one button click to take photo and send the email...


Taifun