Nathan Ford
Posts: 0
Joined: Mon Jul 21, 2014 9:56 am

SendGrid Photograph, easy solution?

I have a form which is essentially a 'Repair Reporting' tool for a social housing landlord. A good feature for this form would be the ability to take a picture of the repair and email it via 'SendGrid' along with the rest of the information in the form.

Is there a simple way of doing this, as everything I have tried so far does not work.

If there is not a simple way, are their any step by step guides to doing it.

Note: I am not a coding wizard, but can code a little.

Thanks

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

SendGrid Photograph, easy solution?

Hi Nathan,

Here is how to do it:

1) Take a photo and save it in a localStorage variable 'photo_buffer':
http://devcenter.appery.io/tutorials/...

2) Add the following code to a mapping of message text:
prevar photo_buffer = localStorage.getItem("photo_buffer");
return 'img ';/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

SendGrid Photograph, easy solution?

Hi,
I have added the code above to send photo with sendgrid, the code to send the message works all sendgrid settings are good.

Have I added the code correctly?

thanks

codevar name = localStorage.getItem("_name") + "\n&quot

var mobile = localStorage.getItem("_mobile") + "\n&quot

var email = localStorage.getItem("frominput") + "\n&quot

var address1 = localStorage.getItem("address1") + "\n&quot

var address2 = localStorage.getItem("address2") + "\n&quot

var postcode = localStorage.getItem("postcode") + "\n&quot

//var problem = Apperyio('probselectmenu').val() + "\n&quot

var problemmessage = localStorage.getItem("problemmessage") + "\n&quot

var photo_buffer = localStorage.getItem("photo_buffer");

return " Name: " + name + " "+ "Mobile Number: " + mobile + " "+ "Email: " + email + " "+ "Address1: " + address1 + " "+ "Address2: " + address2 + " "+ "Postcode: " + postcode + " " + "Problem Details: " + problemmessage + " "+ "Problem Image: " + photo_buffer + " &quot
/code

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

SendGrid Photograph, easy solution?

sorry the problem is after taking the photo on iphone, click use photo complete the form and save all values in localstorage the spinner spins for a while but no message, cant use console or weinre to check.
any Ideas how to sort this?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

SendGrid Photograph, easy solution?

Hello Michael:)

Your code looks correct. Not sure why it doesn't work... Please try adding alerts in code and on service events.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

SendGrid Photograph, easy solution?

Note, code is incorrect in Katya's comment. Should be as like that:

prevar photo_buffer = localStorage.getItem("photo_buffer");
return '<img src="data:image/jpeg;base64,' + photo_buffer + '">&#39/pre

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

SendGrid Photograph, easy solution?

Thanks Maryna,
added code but if I take a photo and send message nothing turns up.
(see screenshot)
When I send image without photo message arrives. (see screenshot)
in weinre on the network tap you can see the first (Tunnel) message is successful
on the second tunnel is with photo and is pending and no message arrives
I tried to check localstorage in weinre but theres nothing there at all

Image Image
Image
Image

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

SendGrid Photograph, easy solution?

OK so this is the weinre network tab when I open the app,
you can see the app reg for push and the login,
first tunnel is the message sent without photo,
the next pending is the photo being taken and it appears on the screen
and the last tunnel is the message being sent with photo. doesnt get sent
the email above is the 1 sent without photo

Michael4771079
Posts: 0
Joined: Sat Jul 21, 2012 2:03 pm

SendGrid Photograph, easy solution?

Hi,
I posted the wrong sendgrid js image yesterday, this is the correct one.
Can someone tell me on the screenshot of weinre where the camera appears to be pending, is this normal?
or is this the problem with image not being sent

Thanks

Image

Return to “Issues”