Skip to Content

C4C - Email with attachment

Hello Experts,

I tried following the below blog, and I was able to send email successfully, However, attachments are not created.

Email with New Functionality:

https://blogs.sap.com/2015/02/03/new-email-functionality-for-tenants-1502-sp01/

The below code doesn't generate PDF so the flow within the if loop is never reached.


/// Attachment related
var Attachments : collectionof Platinum: Attachment;
var Attachment : Platinum: Attachment;
var ATTACHMENT_TYPE_DOCUMENT : DocumentTypeCode;
var FormTemplateLanguage = "E";
var FormTemplateCode : OutputRequestFormTemplateCode;

FormTemplateCode.content = "YGGQTH84Y_PAE";
ATTACHMENT_TYPE_DOCUMENT.content = "10001";

var pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);
if (!pdfDocument.content.IsInitial()) {
Trace.Info("document successfully created");
Attachment.Binary=pdfDocument.content;
Attachment.FileName="hello.pdf";
Attachments.Add(Attachment);
}

Please support.

Thanks

Gayathri


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Nov 08, 2016 at 02:54 AM

    Hi Gayathri,

    Variable Attachments is not initialized.

    Also you could refer:

    https://blogs.sap.com/2013/12/03/how-to-send-an-email-with-attachments-in-sap-cloud-application-studio/

    Thanks, Pradeep.

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Pradeep,

      Thanks for your response.

      But here -->

      var pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);

      The above line doesn't return a PDF doc. For which, the FormTemplateCode and FormTemplateLanguage are set.

      Is there any thing else..

      Thanks

      Gayathri.R

  • Nov 08, 2016 at 10:06 AM

    Hi Gayathri,

    Check this:

    https://archive.sap.com/discussions/thread/3627237

    Thanks, Pradeep.
    Add comment
    10|10000 characters needed characters exceeded

    • Hi Pradeep,

      Jut now identified, I have passed the Form Group code instead of Form Template Header code. When i passed that the form got generated successfully,

      Thanks for your support,

      Gayathri