cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to send Email through ABSL Code

Former Member
0 Kudos

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-stud... )

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

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member200567
Active Contributor

Hi Nabarun,

Just noticed by a quick look that you haven't called instemail.Send() in your code.

Best Regards,

Fred

Former Member
0 Kudos

Hi Fred,

Thanks for reply I'll try and let you know the outcome

Regards

Nabarun Barua

Former Member
0 Kudos

Hi Fred,

I used instemail.send() function then to email didn't triggered. Can you suggest what else could be wrong in my code.

Regards

Nabarun Barua

former_member200567
Active Contributor
0 Kudos

Hi Nabarun,

You need to check "Save After Execution" check box in the event handler on UI designer.

Best Regards,

Fred