If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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

Native Development

Reply
Contributor
bhargav3132
Posts: 18
Registered: ‎05-15-2013
My Device: 9700
My Carrier: 919909743132

BB 10 Cascades qml sending a simple email

I found one example in the the git hub for BB 10 for sending an email, but it looks pretty complicated and alot done in C.

does anyone have an example on how to send a quick email using QML. I don't need any buttons or text fields, just hard coded values.

I found this simple snip, but dont' know how to integrate it.

https://developer.blackberry.com/cascades/documentation/device_platform/pim/messages.html

Any help would be appreciated.

Please use plain text.
Contributor
ketan_patel25
Posts: 34
Registered: ‎05-02-2013
My Device: 9700
My Carrier: Idea

Re: BB 10 Cascades qml sending a simple email

in main.cpp after creating your QmlDocument, qml->setContextProperty("yourshortcut", object);

if(reply) {
reply->setParent(this);
QObject::connect(reply, SIGNAL(finished()),this, SLOT(onInvokeResult()));
_invokeTargetReply = reply;
}
delete reply;
}

void xxx::smileysurprised:nInvokeResult()
{
// Check for errors
switch(_invokeTargetReply->error()) {
// Invocation could not find the target
// did we use the right target ID?
case InvokeReplyError::NoTarget: {
qDebug() << "invokeFinished(): Error: no target" << endl;
break;
}
// There was a problem with the invoke request
// did we set all the values correctly?
case InvokeReplyError::BadRequest: {
qDebug() << "invokeFinished(): Error: bad request" << endl;
break;
}
// Something went completely
// wrong inside the invocation request
// Find an alternate route :smileysad:
case InvokeReplyError::Internal: {
qDebug() << "invokeFinished(): Error: internal" << endl;
break;
}
//Message received if the invoke request is successful
default:
qDebug() << "invokeFinished(): Invoke Succeeded" << endl;
break;
}

// A little house keeping never hurts...
delete _invokeTargetReply;
}

Then in QML call the C++ function invokeEmail using the shortcut you created with the context property. I use this to invoke the email card
Please use plain text.
Developer
peter_strange
Posts: 19,601
Registered: ‎07-14-2008
My Device: Not Specified

Re: BB 10 Cascades qml sending a simple email

This is not the BB10 forum,  Please post BB10 questions and response here:

http://supportforums.blackberry.com/t5/Cascades-Development/bd-p/Cascades

Please use plain text.
Developer
Zymatic
Posts: 144
Registered: ‎12-18-2010
My Device: Limited Edition Z10 & Blackberry Playbook
My Carrier: Rogers Wireless

Re: BB 10 Cascades qml sending a simple email

Here is how I am doing it from QML in my applications

 

Menu.definition: MenuDefinition {
        // Add a Help action
        helpAction: HelpActionItem {
            attachedObjects: [
                Invocation {
                    id: invoke
                    query {
                        //id: invokeQuery
                        uri: "mailto:address@domain.com?subject=Insert%20Subject"
                        invokeActionId: "bb.action.SENDEMAIL"
                        invokeTargetId: "sys.pim.uib.email.hybridcomposer"
                    }
                }
            ]
            onTriggered: {
                invoke.trigger("bb.action.SENDEMAIL");
            }
        }
}

 

In my apps, the above snippet is part of a menu item.  When the menu item is clicked, or triggered, it opens the e-mail composer nad populates the To field and the Subject.  The user can then input the body text and click on send.

 

see documentation https://developer.blackberry.com/cascades/documentation/device_platform/invocation/email.html for other examples of ways to invoke the E-mail application.

Playbook Apps:
Touch Painter, LinkShrink

BB10 Apps:
NoteToSelf , LinkShrink
Please use plain text.
Contributor
BerryBlack13
Posts: 17
Registered: ‎04-09-2013
My Device: developer
My Carrier: kpn

Re: BB 10 Cascades qml sending a simple email

Even faster is using html in a label in QML:

 

Label {
              text: "<html><a href='mailto: mail@mail.com'>mail@mail.com</a></html>"
              textFormat: TextFormat.Html

}

 

This example is easy but limited. Best way is the invocation framework as described in the above post.

Please use plain text.