web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Generate PDF file using JavaScript in Dynamics CRM

(0) ShareShare
ReportReport
Posted on by

I want to convert a ".rdl" report to PDF format using JavaScript and send it with an attachment, the PDF file is attached to the email, but when I send it and open it, the PDF file shows an opening error.

Is there any consideration I should have?

*This post is locked for comments

I have the same question (0)
  • Kokulan Profile Picture
    18,054 on at

    Hi

    It might help if you could add some screenshots and possibly the bit of code that downloads the PDF and then attaches to the email.

    Normally converting to PDF and attaching it to email is done using Server Side Code either using a plugin or CWA.

    If you are doing both of these using JS, please make sure the file size is as expected and also make sure the correct mimetype is set

    The following link has a C# example but the approach is still the same if you are converting an SSRS report to PDF.

  • Community Member Profile Picture
    on at

    In the email it appears attached, the size is 357 bytes, mail reaches me of 679 bytes.

    Captura01.JPG

    And this is the code that I use to attach the file:

    function CreateEmailAttachment(bdy,emailuno) {
    
    
        var activitymimeattachment = Object();
        activitymimeattachment.ObjectId = Object();
        activitymimeattachment.ObjectId.LogicalName = "email";
        activitymimeattachment.ObjectId.Id = emailuno;
        activitymimeattachment.ObjectTypeCode = "email";
        activitymimeattachment.Subject = "File Attachment";
        activitymimeattachment.Body = bdy;
        activitymimeattachment.FileName = "Enviar Oferta.pdf";
        activitymimeattachment.MimeType = "application/pdf";

    }

  • Community Member Profile Picture
    on at

    The "CreateEmailAttachment" function is executed after the encodePdf function

  • Community Member Profile Picture
    on at

    I have also detected that the pdf file that I receive in the email marks the following error:

    " Error.
    Try this action again. If the problem persists, consult the Microsoft Dynamics 365 Community for solutions or contact your organization's Microsoft Dynamics 365 administrator. Ultimately, you can contact Microsoft Technical Support. "


  • Verified answer
    Pawar Pravin  Profile Picture
    5,237 on at

    Hello,

    Please refer following url for reference:

    jsfiddle.net/.../0816jdfq

    ankit.inkeysolutions.com/.../dynamics-crm-2011-creating-e-mail.html

    community.dynamics.com/.../205829

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans