5

電子メールを送信するための BB 10 の git ハブで 1 つの例を見つけましたが、かなり複雑で、多くの部分が C で行われているように見えます。

QMLを使用して簡単な電子メールを送信する方法の例はありますか? ボタンやテキスト フィールドは必要ありません。ハード コードされた値だけが必要です。

この単純なスニップを見つけましたが、統合する方法がわかりません。

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

どんな助けでも大歓迎です。

4

2 に答える 2

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);
            }
        }
    ]
}
于 2013-07-11T05:57:02.933 に答える
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を呼び出します。これを使ってEメールカードを呼び出します

于 2013-02-07T19:46:18.170 に答える