Hi Experts,
I've Custom Business Object having Service Agaent / Employee (to whom I've to sent Email) . Now Requirement is when User Press Send Email Button Service Agent / Employee should receive Email with Attachment.
I used following Link for Reference ( https://blogs.sap.com/2013/12/03/how-to-send-an-email-with-attachments-in-sap-cloud-application-studio/ )
Note: Business Object Email Activity has been deprecated by sap so couldn't be used. Instead SAP has introduce new Business Object Named: Activity. Therefore used new Business Object to send Email.
For Understanding Perpose I'm sending Email to myself. But Email is not getting Triggered, not able to understand what went wrong.
Below is the Actual Code I used.
/*
Add your SAP Business ByDesign scripting language implementation for:
Business Object: BO_SendEmail
Node: Root
Action: CreatePDF
Note:
- To access the elements of the business object node,
use path expressions, for example, this.<element name>.
- To use code completion, press CTRL+J.
*/
import ABSL;
import AP.Common.GDT;
import AP.FO.Activity.Global;
import AP.PC.ActivityManagement.Global;
import BASIS.Global;
import DocumentServices.Global;
//Declaration of Business Object
var ATTACHMENT_TYPE_DOCUMENT : DocumentTypeCode;
ATTACHMENT_TYPE_DOCUMENT.content = "10001";
//PDF File Name Generation
var timestamp = Context.GetCurrentSystemTimeStamp();
var stimestamp = timestamp.ToString();
var documentAlternativeName = "Inspection";
documentAlternativeName = documentAlternativeName + stimestamp + ".pdf";
var description : Description;
var documentName = "Inspection1";//.pdf";
documentName = documentName + stimestamp + ".pdf";
// create PDF
var pdfDocument;
var FormTemplateLanguage = "E";
var FormTemplateCode : OutputRequestFormTemplateCode;
FormTemplateCode.content = "YGZB3916_PXBI7";//Template Code
pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);
//Email Root
var EmailRoot : elementsof Activity;
var instemail;
//Email define Party Node
var EmailParty : elementsof Activity.Party;
var instparty;
//Email Text Collection
var emailTxtCollTxt: elementsof Activity.TextCollection.Text;
var emailTxtCollTxtCntnt: elementsof Activity.TextCollection.Text.TextContent;
var instEmailTxtColl;
var instEmailTxtCollTxt;
// Email Activity define attachment folder
var emailAttachmDoc: elementsof Activity.AttachmentFolder.Document;
var instEmailAttachm;
// Creation Email Starts
EmailRoot.TypeCode = "39";
EmailRoot.SubjectName = "Test for sending Email with Attachment";
instemail = Activity.Create(EmailRoot);
EmailParty.PartyName = "8000000004";// This is my Business Partner Internal ID
instemail.MessageToParty.Create(EmailParty);
// Create a text of type "Body Text"
instEmailTxtColl = instemail.TextCollection.Create();
emailTxtCollTxt.TypeCode.content = "10002";
instEmailTxtCollTxt = instEmailTxtColl.Text.Create(emailTxtCollTxt);
emailTxtCollTxtCntnt.Text.content = "This is Body Text of Test Email for sending Attachment";
instEmailTxtCollTxt.TextContent.Create(emailTxtCollTxtCntnt);
// Create an attachment
instEmailAttachm = instemail.AttachmentFolder.Create();
//emailAttachmDoc.
instEmailAttachm.CreateFile(ATTACHMENT_TYPE_DOCUMENT, documentName, documentAlternativeName, description, pdfDocument);
As if now This perticular Action is Excuting without error but no Email is geting Triggered.
If any one can let me know what went wrong in above code or what I've missed
Regards
Nabarun Barua