cancel
Showing results for 
Search instead for 
Did you mean: 

Send automatically notification email

Former Member
0 Kudos

Hi Everybody

I'm investigating about how to send notifications mails after an operation, I found a BO named "EmailActivity", apply the example code but I don't understand where it takes the mail I don't have errors in the syntaxis, but in the moment of run the code shows this message:

import ABSL;
import AP.FO.Activity.Global;

//EmailActivity: Root node
var elEmailRoot :  elementsof EmailActivity;
var instEmail;

// EmailActivity: define party node
var elEmailParty : elementsof EmailActivity.Party;
var instParty;

// EmailActivity: define service order text collection
var TXT_TYPE_BODY_TEXT = "10002";
var elEmailTxtCollTxt:      elementsof EmailActivity.TextCollection.Text;
var elEmailTxtCollTxtCntnt: elementsof EmailActivity.TextCollection.Text.TextContent;
var instEmailTxtColl;
var instEmailTxtCollTxt;

// EmailActivity: maintain description - mandatory
elEmailRoot.Name.content = "PSM CRM ABSL Test - CallEmailExample Example_01";

// EmailActivity: create new instance
instEmail = EmailActivity.Create(elEmailRoot);

// Email: Organizer party - mandatory
if (! instEmail.MessageFromParty.IsSet()) {
 
  elEmailParty.PartyKey.PartyID.content = "00163E0312B41EE2B3A85F4B8DB6EEFE";
  //elEmailParty.AddressReference.AddressHostUUID.content

  instEmail.MessageFromParty.Create(elEmailParty);
}


// Email: Set Employee Responsible  mandatory
if (! instEmail.EmployeeResponsibleParty.IsSet()) {
  elEmailParty.PartyKey.PartyID.content = "00163E0312B41EE2B3DA1D0FADD9E7FB"; // Set Employee ID
  instEmail.EmployeeResponsibleParty.Create(elEmailParty);
}

// Create a text of type "Body Text"
instEmailTxtColl = instEmail.TextCollection.Create();
elEmailTxtCollTxt.TypeCode.content = TXT_TYPE_BODY_TEXT;
instEmailTxtCollTxt = instEmailTxtColl.Text.Create(elEmailTxtCollTxt);
elEmailTxtCollTxtCntnt.Text.content = "Texto del e-mail";
instEmailTxtCollTxt.TextContent.Create(elEmailTxtCollTxtCntnt);

How to send automatically notification email?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos
Hi,
I think Arnulfo's reply is correct and the "Send" action is missing in the code snippet. Additionally, the receipient (
MessageToParty) is not maintained.
The following code snippet worked in my test system:
import ABSL;
import AP.FO.Activity.Global;
import AP.PC.IdentityManagement.Global;
import AP.FO.BusinessPartner.Global;
//EmailActivity: Root node
var elEmailRoot :  elementsof EmailActivity;
var instEmail;
// EmailActivity: define party node
var elEmailParty : elementsof EmailActivity.Party;
var instParty;
// EmailActivity: define service order text collection
var TXT_TYPE_BODY_TEXT = "10002";
var elEmailTxtCollTxt:      elementsof EmailActivity.TextCollection.Text;
var elEmailTxtCollTxtCntnt: elementsof EmailActivity.TextCollection.Text.TextContent;
var instEmailTxtColl;
var instEmailTxtCollTxt;
// Determine business partner of current user
var identityUUID = Context.GetCurrentIdentityUUID();
var retrieveSingleIdentity = Identity.Retrieve(identityUUID);
var retrieveSingleBP = BusinessPartner.Retrieve(retrieveSingleIdentity.BusinessPartnerUUID);
// EmailActivity: maintain description - mandatory
elEmailRoot.Name.content = "MailExample Example_01";
// EmailActivity: create new instance
instEmail = EmailActivity.Create(elEmailRoot);
// Email: Organizer party - mandatory
if (! instEmail.MessageFromParty.IsSet()) {
        elEmailParty.PartyKey.PartyID.content = retrieveSingleBP.InternalID;
  instEmail.MessageFromParty.Create(elEmailParty);
}
// Email: Set Employee Responsible  mandatory
if (! instEmail.EmployeeResponsibleParty.IsSet()) {
  elEmailParty.PartyKey.PartyID.content = retrieveSingleBP.InternalID;
  instEmail.EmployeeResponsibleParty.Create(elEmailParty);
}
// Email: Message to party
elEmailParty.PartyKey.PartyID.content = "8000001620";  // replace with business partner from your system!
instEmail.MessageToParty.Create(elEmailParty);
// Create a text of type "Body Text"
instEmailTxtColl = instEmail.TextCollection.Create();
elEmailTxtCollTxt.TypeCode.content = TXT_TYPE_BODY_TEXT;
instEmailTxtCollTxt = instEmailTxtColl.Text.Create(elEmailTxtCollTxt);
elEmailTxtCollTxtCntnt.Text.content = "This is a test email...";
instEmailTxtCollTxt.TextContent.Create(elEmailTxtCollTxtCntnt);
// Call Send action
instEmail.Send();
Also, please make sure that for the business partners used (in MessageFromParty, EmployeeResponsibleParty, MessageToParty) a valid email address is maintained in your system.

The instances of the EmailActivity business object that were successfully saved, can be found in work center "Account Management" -> View "Activities".

Best regards,

Kornelia

Former Member
0 Kudos

Hi Kornelia

    Yes, this code has work fine but it just generate one record in "Account Management" -> View "Activities".

   customer has not got any mail from this code.


     Any solution.?

    

    

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi everybody,

I found the solution, You have the right answer.
The email address in the system needed to be configured and i added the "send" action.
Thank you!

               instEmail.Send();

Regards!

Former Member
0 Kudos

Hi, I'm not sure if your instance is created correctly, but if it is, you're never using the "Send" action