Email and Attachments in Kony (or sending vCard Contact information)

1.1k Views Asked by At

I am trying to send an attachment using JavaScript in Kony Studio version 5 (the point of this is to provide an email with a vCard Contact that can be read on an iPhone or Android device).

Unfortunately the documentation is rather scant and I have not been able to get it to work. Here is what I am trying:

    var attachmentBody = "this would be the vCard contact as simple text!";
    var attachments = { "mimetype" : "text/vcard", "attachment" : attachmentBody };        
    var msgBody = "Hello from the message body...";
    kony.phone.openEmail(to, cc, bcc, sub, msgBody, false, attachments);

This does NOT provide an attachment at all. :(

  1. List item
  2. Does anyone have any experience with using attachments?
  3. Does anyone have a code sample of how to use one from Kony using JavaScript?
  4. If not, does anyone have a sample of FFI that might work?
2

There are 2 best solutions below

0
On

Just a call out to the folks on this forum: this was answered on the Kony forums under this response: http://developer.kony.com/konyforum/viewtopic.php?id=3900

function generateVCard(){


   var email=frmDetails.lblEmail.text;
   var off=frmDetails.lblOff.text;
   var mob=frmDetails.lblMob.text;
   var fullName = frmDetails.lblName.text
   var lname= frmDetails.lbllname.text;
   var fname=frmDetails.lblfname.text
   var offName= frmDetails.lblLocOff.text;
   var jbTitle = frmDetails.lblDetDesg.text
   var conList = "BEGIN:VCARD\r\n";
        conList += "VERSION:3.0\r\n";
        conList += "N:"+lname+";"+fname+"\r\n";
        conList += "FN:"+fullName+"\r\n";
        conList += "ORG:"+offName+"\r\n";
        conList += "TITLE:"+jbTitle+"\r\n";
        conList += "TEL;TYPE=WORK,VOICE:"+off+"\r\n";
        conList += "TEL;TYPE=HOME,VOICE:"+mob+"\r\n";
        conList += "ADR;TYPE=WORK:"+offName+"\r\n";
        conList += "EMAIL;TYPE=PREF,INTERNET:"+email+"\r\n";
        conList += "END:VCARD\r\n";
        kony.print("VCF : "+conList);
    var encStr = Base64.encode(conList);
    kony.print("Encoded string - : "+encStr);
    var rawStr = kony.convertToRawBytes(encStr);
    return rawStr;


 }

function mailAttach(){
    kony.print("Email id:");
    var lname= frmDetails.lbllname.text;
       var fname=frmDetails.lblfname.text
       var fulName = fname +"_"+ lname+".vcf";
       kony.print("FULLNAME:"+fname +"_"+ lname);
    var to=[];
    var cc=[];
    var bcc = [];
    var sub = "Get Connected with "+fname+" "+lname;
    var msgbody = "";
    var rawBytes = generateVCard();
    kony.print(rawBytes);
    tab= [ { mimetype : "text/x-vcard",  attachment : rawBytes , filename : fulName }]; 
    kony.print("tab>>>>");
    kony.print(tab);
    kony.phone.openEmail(to, cc, bcc, sub, msgbody,false, tab);
    kony.print("after open email");
}
0
On

This you cannot achieve directly using kony apis. you will have to use native functionality and then use it as FFI (Foreign Function Interface) in kony. here is link for more details of FFI https://www.linkedin.com/groups/Foreign-Function-Interface-most-powerful-4981807.S.256063126

video for same. http://www.youtube.com/watch?v=lf60so3AwP8