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
Highlighted
Developer
Posts: 85
Registered: ‎06-22-2013
My Device: N/A
My Carrier: N/A
Accepted Solution

Sending Email With attachment.

Hello Guys,

 

I need to send an email with attached image.

i have composed an email with prepopulated fields,

 

void SocialInvocation::sendEmail(const QString &uri) {

      InvokeRequest request;
      request.setTarget("sys.pim.uib.email.hybridcomposer");
      request.setAction("bb.action.COMPOSE");
      request.setMimeType("message/rfc822");
      QVariantMap data;
      data["to"] = "mail@yahoo.com";
      data["subject"] = "Test";
      data["body"] = "Body";
      data["attachment"] =  QDir::currentPath() + "/app/native/assets/image.jpg";
      QVariantMap moreData;
      moreData["data"] = data;

     bool ok;

     request.setData(bb:Smiley TonguepsObject::encode(moreData, &ok));

     m_invokeManager->invoke(request);

}

 

It works fine, but there is an error in attached image (Size 0b) and when i send the email it delivered successfully but with no Images.

   

 

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Sending Email With attachment.

This won't work because the files under app/ (and also data/) will not be readable by anything outside of your app, and that includes the PIM.

I believe copying the file to ./sharewith/pim before attaching them is the intended approach, although to be honest I haven't seen this documented yet.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Sending Email With attachment.

I can save and load, but using invoke to compose email still attaches 0 bytes file.

--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development
Developer
Posts: 849
Registered: ‎03-03-2011
My Device: Z10

Re: Sending Email With attachment.

If I use attach-only invocation, it works properly regardless to the directory.
--------------------------------------------------------------------------------------
Leader of Ljubljana BlackBerry Developer Group
BlackBerry Certified Builder for Native Application Development