locked
How to write contents of Body of Activity Mime Attachement Entity using Javascript CRM 2011 How? RRS feed

  • Question

  • Hello Experts,

    My requirement is to add ana attachement to the email ,I am using the following code for create activity MIME atachement using javascript.I am able to create attachement but I am not able to write the contents to that attachment ,How can I do that .(iam using Body attribute for email attachment but no contents are passed to that attacement. any one please suggest how can I do that. I pasted my code here.

    function CreateEmailAttachment(actvid) {

     

    //get reporting session and use the params to convert a report in PDF

    // var params = getReportingSession();

    debugger;

    //Email attachment parameters

    var activitymimeattachment = Object();

    activitymimeattachment.ObjectId = Object();

    activitymimeattachment.ObjectId.LogicalName =

    "email";

    activitymimeattachment.ObjectId.Id = actvid;

    activitymimeattachment.ObjectTypeCode =

    "email",

    activitymimeattachment.Subject =

    "File Attachment";

    //activitymimeattachment.Body = "Sample content";

    //SaveAsFile();

    var sample="Hello World";

    // activitymimeattachment.Body = sample;

    activitymimeattachment.FileName =

    "Provider Route Information.txt";

    //activitymimeattachment.Body = encode64("data");

    var data="hhjhjshghdghsdghs";

    //activitymimeattachment.Body = encode64(data);

    //Attachment call

    //activitymimeattachment.MimeType = "application/txt";

    activitymimeattachment.MimeType =

    "text/plain";

    SDK.JQuery.createRecord(activitymimeattachment,

    "ActivityMimeAttachment", ActivityMimeAttachmentCallBack, errorHandler);

    Thanks and Regards

    Muralikrishna

    Friday, August 9, 2013 5:14 AM

All replies

  • activitymimeattachment.Body is commented out?

    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Friday, August 9, 2013 7:16 AM
  • Hi,

    I commented that statement. if i am using Body ,the attachment is not creating ,that's why I commented .

    Even though I am using that the contents are not writable into that attachment (text file).Body is of type 'String ' only then why It is not allowing the contents,I noticed that contents should be encoded into 64 format  before writing to attachment.can you please help me how can I write contents to that attachement while creating.

    Thanks and regards

    Murali

    Friday, August 9, 2013 7:49 AM
  • Take a look at this blog post which explains how to create the attachment using a pdf, but you can see how you need to set the Body by encoding it.

    http://ankit.inkeysolutions.com/2012/11/dynamics-crm-2011-creating-e-mail.html

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Friday, August 9, 2013 9:41 AM
  • Did you manage to get this working? If so please close this thread as answered.

    Thanks

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Saturday, August 10, 2013 8:58 PM
  • Hi Murali,

    I am also having the same issue. if you find the solution please share it.

    Thanks

    Dinesh

    Friday, October 9, 2015 11:52 AM