我在发送电子邮件的BB 10的git hub中找到了一个示例,但它看起来非常复杂,很多用C语言完成。
有没有人举例说明如何使用QML发送快速电子邮件。我不需要任何按钮或文本字段,只需要硬编码值。
我发现这个简单的剪辑,但不知道如何整合它。
https://developer.blackberry.com/cascades/documentation/device_platform/pim/messages.html
任何帮助都将不胜感激。
答案 0 :(得分:7)
以下代码将打开一张包含所有指定电子邮件字段的电子邮件编辑器的工作表:
import bb.cascades 1.0
Page {
Container {
horizontalAlignment: HorizontalAlignment.Fill
layout: DockLayout {
}
Container {
horizontalAlignment: HorizontalAlignment.Center
verticalAlignment: VerticalAlignment.Center
TextArea {
id: emailBody
}
Button {
text: "Send email"
onClicked: {
emailInvocation.query.uri = "mailto:someemailadress@cookbook.xyz?subject=Test&body=" + emailBody.text
emailInvocation.query.updateQuery();
}
}
}
}
attachedObjects: [
Invocation {
id: emailInvocation
query.mimeType: "text/plain"
query.invokeTargetId: "sys.pim.uib.email.hybridcomposer"
query.invokeActionId: "bb.action.SENDEMAIL"
onArmed: {
emailInvocation.trigger(emailInvocation.query.invokeActionId);
}
}
]
}
答案 1 :(得分:0)
在创建QmlDocument后的main.cpp中,qml-> setContextProperty(“yourshortcut”,object);
void xxx::invokeEmail(){
InvokeManager invokeManager;
InvokeRequest request;
request.setTarget("sys.pim.uib.email.hybridcomposer");
request.setAction("bb.action.COMPOSE");
request.setMimeType("message/rfc822");
InvokeTargetReply *reply = invokeManager.invoke(request);
if(reply) {
reply->setParent(this);
QObject::connect(reply, SIGNAL(finished()),this, SLOT(onInvokeResult()));
_invokeTargetReply = reply;
}
delete reply;
}
void xxx::onInvokeResult()
{
// 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 :(
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;
}
然后在QML中使用您使用context属性创建的快捷方式调用C ++函数invokeEmail。我用这个来调用电子邮件卡