# Problem sending SMS or email with sample form

**URL:** <https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316>\
**Category:** Support\
**Tags:** odk-collect\
**Created:** [March 6, 2020, 3:07am UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316 "2020-03-06T03:07:43Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![alios82](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@alios82](https://forum.getodk.org/u/alios82)\
**Post date:** [March 6, 2020, 3:07am UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/1 "2020-03-06T03:07:43Z")

</div>

Hi  
The external application launch (email and SMS) functioanlity is broken at the moment in ODK collect latest version.

Passing ${send\_to} and ${message} as raw strings works but the odk collect application crashes when using variables for $send\_to.  
The ${message} variable doesnt crash the application but it never gets passed to the external application e.g. SMS or gmail etc.

Please validate if this is a one off issue or fix as early as possible if its pervasive.  
Thanks and regards,  
Ali

---

<div class="post-metadata">

**Author:** ![safi](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@safi](https://forum.getodk.org/u/safi)\
**Post date:** [March 6, 2020, 3:15am UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/2 "2020-03-06T03:15:08Z")

</div>

Hi  
I am actually using the example from release notes and experiencing the same problem while using the exact form from the release notes. [https://docs.google.com/spreadsheets/d/1hep9Ibtd2u3rtPviNn8HS0qbwjGoJy4JtZOn6xdHkMk/edit#gid=0](https://docs.google.com/spreadsheets/d/1hep9Ibtd2u3rtPviNn8HS0qbwjGoJy4JtZOn6xdHkMk/edit#gid=0)

Any help in this regard will be very appreciated. Thank you.

---

<div class="post-metadata">

**Author:** ![LN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ln/32/1605_2.png) [@LN](https://forum.getodk.org/u/LN)\
**Post date:** [March 6, 2020, 4:32am UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/3 "2020-03-06T04:32:52Z")

</div>

Can you please both let us know what versions of Android you are using, what devices you have, and what SMS and email applications you are using?

It would also be helpful to know if you see any kind of dialog or message when Collect crashes. I just tried the sample form again and it worked as expected for me. @alios82, did you try the sample form without any modification?

---

<div class="post-metadata">

**Author:** ![safi](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@safi](https://forum.getodk.org/u/safi)\
**Post date:** [March 6, 2020, 9:53pm UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/4 "2020-03-06T21:53:27Z")

</div>

Using Android 7.0 on Samsung Galaxy S8.  
SMS Application is "Messages 4.2.03.12"  
Email Application is "Gmail 8.4.8.194949231"  
I don't get any message when it crashes.

i used:  
**ex:android.intent.action.SENDTO(uri\_data='smsto:5555555', sms\_body=${message})**  
from [https://docs.opendatakit.org/launch-apps-from-collect/](https://docs.opendatakit.org/launch-apps-from-collect/)

i was concating 'smsto:5555555', storing it in a variable and equating that to uri\_date. That was causing the crash, then i copied the example from the sample form where the "uri\_data" and "sms\_body" are flipped e.g:

**ex:android.intent.action.SENDTO(sms\_body=${message}, uri\_data=${send\_to})**

That worked as expected.

So the example in the documentation needs to be fixed.

---

<div class="post-metadata">

**Author:** ![LN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ln/32/1605_2.png) [@LN](https://forum.getodk.org/u/LN)\
**Post date:** [March 6, 2020, 10:14pm UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/5 "2020-03-06T22:14:23Z")

</div>

I'm glad you've got it working, @safi!

I've confirmed that the implementation doesn't expect any particular order for the two values. I tried flipping it in my test form and everything still works as expected. If you can share an XLSForm that crashes, we might be able to identify an underlying issue if there is one.

---

<div class="post-metadata">

**Author:** ![safi](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/s/d26b3c/32.png) [@safi](https://forum.getodk.org/u/safi)\
**Post date:** [March 7, 2020, 12:54am UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/6 "2020-03-07T00:54:19Z")

</div>

Thanks LN. You are right it does work both ways.  
I think I have finally found the actual problem.  
When Send To intent is used in a repeat group, ODK collect crashes. I tried using it in a repeat group, in a regular group and without any groups. it works fine for regular groups and without groups, but when used in a repeat group, ODK Collect crashes.

Also when I tried using the repeat group example from sample form it gave me an **error** saying

**"The requested application is missing. Please Manually enter the reading"**

Is there a solution or a way to open up the sms app within a repeat group?

---

<div class="post-metadata">

**Author:** ![alios82](https://getodk.b-cdn.net/letter_avatar_proxy/v4/letter/a/f1d935/32.png) [@alios82](https://forum.getodk.org/u/alios82)\
**Post date:** [March 8, 2020, 7:29pm UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/7 "2020-03-08T19:29:24Z")

</div>

Hi @LN  
I am using Android 6.0.1 on Samsung galaxy S7 edge.  
The resolution mentioned by Safi worked for me.  
I was also using sms and email within a repeat group.  
It works fine outside of repeat group and independent of order of parameters.

---

<div class="post-metadata">

**Author:** ![LN](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/ln/32/1605_2.png) [@LN](https://forum.getodk.org/u/LN)\
**Post date:** [March 13, 2020, 10:07pm UTC](https://forum.getodk.org/t/problem-sending-sms-or-email-with-sample-form/25316/8 "2020-03-13T22:07:41Z")

</div>

> [@safi](#):
>
> but when used in a repeat group, ODK Collect crashes

Could you share a sample form that has this problem? When using repeats, you do have to be careful about indexing and in general there's more complexity there. I can imagine various reasons why you'd be getting a crash.

> [@safi](#):
>
> when I tried using the repeat group example from sample form it gave me an **error**

Aha! Now this is kind of a bewildering one and might explain why you had different behavior based on parameter ordering. The `sms_body` value in that sample form is `"Thank you we can't wait to see you on the study start date."` which contains an apostrophe. It turns out that the code used to separate out parameters treated it as a quote that never got closed and so the `uri_data` parameter after it wasn't identified. However, if `uri_data` comes before, `sms_body` can contain apostrophes without any problems. I must have changed something in the form definition that I thought was inconsequential like the contents of the message or the order of the parameter after trying the form.

For now, I recommend putting `uri_data` first so you don't have to think about this quirk. I have filed an issue at [https://github.com/opendatakit/collect/issues/3711](https://github.com/opendatakit/collect/issues/3711) and hope we can fix it soon.
