Skip to Content
0

Unable to send Email through ABSL Code

Feb 27, 2017 at 12:20 PM

118

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Fred K Feb 28, 2017 at 01:33 AM
0

Hi Nabarun,

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

Best Regards,

Fred

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Fred,

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

Regards

Nabarun Barua

0

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

0

Hi Nabarun,

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

Best Regards,

Fred

0