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
New Contributor
Posts: 4
Registered: ‎09-17-2013
My Device: Z10
My Carrier: Airtel

BB10 invokeManager for email

[ Edited ]

Hi,

 

I am facing issue with imvokeManager for email.

I have added my code snippet below.

 

InvokeManager is not invoking email client if the body text has some special charecters like :, #, [ etc.

 

Please let me know how to fix the issue.

 

I tried with setData. But it doesn't populate data in email subject or body.

 

Please let me know the solution for this issue.

 

InvokeManager invokeManager;

InvokeRequest request;

QString data;

bool ok;

data.

append(articleText + "\n\n" + sharingText + "\n\n" + AppConfig::instance()->getConstants()->SHARE_EMAIL_BODY + "\n" + AppConfig::instance()->getConstants()->SHARE_APP_URL);

// data.append("{\"body\":\"dfsgdgrehthrth\"}");

QString uriStr;

uriStr.append(

"mailto:?subject=");

uriStr.

append(articleText).append("&body=").append(data.toUtf8());

 

request.

setTarget("sys.pim.uib.email.hybridcomposer");

 

request.

setAction("bb.action.OPEN, bb.action.COMPOSE, bb.action.SENDEMAIL");

request.

setUri(QUrl(QString(uriStr.toUtf8())));

 

 

InvokeTargetReply *reply = invokeManager.invoke(request);

 

Retired
Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

Re: BB10 invokeManager for email

You are trying the uri approach which requries you to % encode the body and subject. Have you done that?

 

Alternatively, you can also try the json approach of invoking email composer documented below. This does not reuquire percent encoding.

https://developer.blackberry.com/native/documentation/cascades/device_platform/invocation/email.html

New Contributor
Posts: 4
Registered: ‎09-17-2013
My Device: Z10
My Carrier: Airtel

Re: BB10 invokeManager for email

Hi Shaque,

 

I have ried all the combinations but none of them worked.

Could you please sahre a code snippet that works @ your end?

 

 

Thanks,

Mousumi 

Developer
Posts: 237
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: BB10 invokeManager for email

This works pretty nice on me

 

void ApplicationUI::invokeEmail(QString email, QString subject, QString body) {
	InvokeRequest request;
	request.setTarget("sys.pim.uib.email.hybridcomposer");
	request.setAction("bb.action.SENDEMAIL");
	request.setUri(
			"mailto:" + email + "?subject=" + subject.replace(" ", "%20")
					+ "&body=" + body.replace(" ", "%20"));
	invokeManager->invoke(request);
}

 

Developer
Posts: 1,168
Registered: ‎03-20-2013
My Device: Red LE Developer Z10
My Carrier: Fido

Re: BB10 invokeManager for email

Just curious why you are using QString.replace() rather than QUrl.toPercentEncoding(), which would handle any special characters too, not just spaces.


nemory wrote:

This works pretty nice on me

 

void ApplicationUI::invokeEmail(QString email, QString subject, QString body) {
	InvokeRequest request;
	request.setTarget("sys.pim.uib.email.hybridcomposer");
	request.setAction("bb.action.SENDEMAIL");
	request.setUri(
			"mailto:" + email + "?subject=" + subject.replace(" ", "%20")
					+ "&body=" + body.replace(" ", "%20"));
	invokeManager->invoke(request);
}

 






Developer of Built for BlackBerry certified multiFEED RSS/Atom feed reader and aggregator.  multiFEED Icon

Play nice: Clicking Like Button on posts that helped you not only encourages others to continue sharing their experience, but also improves your own rating on this board. Also, don't forget to accept a post if it solves your problem or answers your question.
Developer
Posts: 237
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: BB10 invokeManager for email

Thanks. I didn't know there's a function for that