Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: send email/message based off javascript

If I understand correctly,

 

You are trying to create an email that contains the model, software version and pin via an email when someone clicks a button.

 

If that is the case, the below code would work:

 

<script type="text/javascript">
  var body = "Your phone is a " + blackberry.system.model +
     " running " + blackberry.system.softwareVersion + ".\n" + 
     "Your PIN is " + blackberry.identity.PIN;

  var message = new blackberry.message.Message();
  message.toRecipients = "noone@foo.com";
  message.subject = "My information";
  message.body = body;
  message.send();
</script>

 

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
Contributor
Posts: 47
Registered: ‎02-18-2011
My Device: Not Specified

Re: send email/message based off javascript

Awesome. i will play around with that and see eht i ome up with.

My main concern is how can the end user pit in an email? I know how to do it in php.
Contributor
Posts: 47
Registered: ‎02-18-2011
My Device: Not Specified

Re: send email/message based off javascript

how do i make the form look at the javascript and send the mail?? again, im used to php and not js to send emails. thanks
Developer
Posts: 163
Registered: ‎05-06-2011
My Device: Playbook
My Carrier: Not Specified

Re: send email/message based off javascript

In your HTML page you could keep an input field to ask the user to enter email address and a button to send email.Hope this helps.

 

<script type="text/javascript">
function sendMail() {

 //Copied from above post
 var body = "Your phone is a " + blackberry.system.model +
     " running " + blackberry.system.softwareVersion + ".\n" + 
     "Your PIN is " + blackberry.identity.PIN;

  var message = new blackberry.message.Message();
  message.toRecipients = documente.getElementById('email').value;
  message.subject = "My information";
  message.body = body;
  message.send();
}
</script>

<input type="text" id="email" value="" />
<input type="button" onclick="sendMail();" value="Send" />

 

Contributor
Posts: 47
Registered: ‎02-18-2011
My Device: Not Specified

Re: send email/message based off javascript

Thanks.

 

I get local:///sendinfo<br><br>Resource does not exist

 

I am these in my XML

 

 <feature id="blackberry.system" /> 
 <feature id="blackberry.identity" />  
 <feature id="blackberry.invoke.CalendarArguments" /> 
 <feature id="blackberry.invoke" />
 <feature id="blackberry.message" />

 

Contributor
Posts: 41
Registered: ‎07-21-2011
My Device: Superberry
My Carrier: Rogers

Re: send email/message based off javascript

Sounds like you don't have the proper access tag in your config.xml for the file location you're trying to access. Try adding this:

<access subdomains="true" uri="file:///sendinfo"/>
----------------------------------------------------------------------------------------------
I kode for cudos! Or was it the other way around?
Highlighted
New Contributor
Posts: 2
Registered: ‎06-04-2013
My Device: Q10
My Carrier: Company

Re: send email/message based off javascript

I am looking for exactly this function for blackberry os 10, but blackberry.message.Message() didn't support for bb os 10. Do there any function to send email with html button click as blackberry.message function for blackberry os 10? I am doing it on webworks which using javascript and webworks API only. Please suggest.