Skip to Content

 

EDIT – 2017-05-10

The scripting mentioned below seems to be now reprecated, however using the Platinum Engineer library seems that SAP has made it even simpler, I’m attaching the screen capture of the method itself, which I haven’t tried yet, but as soon as I do I’ll update you on this post:

 

Seems to be easier, isn’t it?

 

I’m leaving the original post as is, just for documentation reference.

 

 

Hi people, there’s a guide explaining the configuration needed to send an email from the internal Mail service included in ByD.

 

1. First of all, we need to create a domain, so access the ByD as a key User.

 

2. Then access the Business Configuration > Implementation Projects

Captura.PNG

 

3. Once in there, click the Open Activity List Button

 

Captura1.PNG

 

4. Then go to the fine tuning tab, and in the search field type “Mail”, select the Mail and Fax Configuration, and click the “Open” Button

Captura3.PNG

 

5. A new window will appear, Click the Email and Fax Settings link.. then..

 

6. In the Allowed Sender E-Mail Domains, click add, and write any domain, in this case my domain is HiByDCommunity.com

and leave the other fields as my caption, click save and close

 

Captura4.PNG

 

 

7. Now we’re going to configure our personal Mail, based on the domain that we just added.

Go to the Home WorkCenter, and select the Self Services Overview, Inside the Company Address Book block, click the Edit my Contact Data Link.

 

capture.PNG

 

8. In the EMail field, fill it with an email using the declared domain, click finish.

caption2.PNG

 

Now we are ready to test this up.

 

Use the script example in the PSM, in the EMail Activity section!

 

 

UPDATE:

 

Many of you asked for the script to implement this, so there you go! 😀

 

On this example I created the QA with three input fields, 1 for the email title, another for the email where you want to send the message, and another with the actual 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;

 

 

var TXT_TYPE_BODY_TEXT = “10002”;

var elEmailTxtCollTxt:      elementsof EmailActivity.TextCollection.Text;

var elEmailTxtCollTxtCntnt: elementsof EmailActivity.TextCollection.Text.TextContent;

var instEmailTxtColl;

var instEmailTxtCollTxt;

 

 

elEmailRoot.Name.content = this.asunto; //Here comes the title of the email

 

 

 

instEmail = EmailActivity.Create(elEmailRoot);

 

 

 

elEmailParty.PartyKey.PartyID.content = this.email.content;         //The email address where you want to send it

instEmail.MessageToParty.Create(elEmailParty);

 

 

instEmailTxtColl = instEmail.TextCollection.Create();

elEmailTxtCollTxt.TypeCode.content = TXT_TYPE_BODY_TEXT;

instEmailTxtCollTxt = instEmailTxtColl.Text.Create(elEmailTxtCollTxt);

elEmailTxtCollTxtCntnt.Text.content = this.contenido; //                           Here the message itself

instEmailTxtCollTxt.TextContent.Create(elEmailTxtCollTxtCntnt);

 

instEmail.Send();

 

Update: This script must have the save after execution indicator marked as true.

To report this post you need to login first.

22 Comments

You must be Logged on to comment or reply to a post.

  1. San Ka Ran

    hi i followed this script. But I get an bellow error. what is this error mean?

    Mailing not possible; e-mail address does not exist for sender 8000000165

    (0) 
      1. San Ka Ran

        Thanks Alessandro. Issue Solved. I have filled my E-mail id in service agent. so now mail will go through my default E-mail id.  Can you suggest script for assigning username in program itself!

        (0) 
        1. Hanumath K

          Hi Sankaran,

          Following is the code for to fill the user email address and email it to user from SDK

          //Elements of Email

          var emailActivityElements : elementsof EmailActivity;

          var emailActivityMessageFromPartyElements : elementsof EmailActivity.Party;

          var emailEmployeeResponsiblePartyElements : elementsof EmailActivity.Party;

          var emailActivityCC : elementsof EmailActivity.Party;

          var emailAcitivtyTo : elementsof EmailActivity.Party;

          var emailActivityEmailActivity : elementsof EmailActivity.Party;

          var emailActivityTextCollText : elementsof EmailActivity.TextCollection.Text;

          var emailActivityTextCollTextTextCont : elementsof EmailActivity.TextCollection.Text.TextContent;

          var employeeMailID;

          var employee;

          var employeeAdminMailID;

          var emailActivityInstance;

          employee = Employee.Identification.Retrieve(notification.Source);

          if (employee.IsSet())

          {

              if (employee.ToParent.CurrentDefaultEmployeeWorkplaceAddressInformation.IsSet())

              {

                  var employeeWorkPlaceAddressInfo = employee.ToParent.CurrentDefaultEmployeeWorkplaceAddressInformation;

                    if (employeeWorkPlaceAddressInfo.EmployeeWorkplaceAddressWorkplaceAddress.IsSet())

                    {

                          employeeMailID = employeeWorkPlaceAddressInfo.EmployeeWorkplaceAddressWorkplaceAddress.DefaultEMail.URI.content;

                    }

                }

          }

              //For display the subject accordingly

            

                  emailActivityElements.Name.content = “Reg: Test Email”;

                  emailActivityInstance = EmailActivity.Create(emailActivityElements);

              // for assigning the To Party

              if (!employeeMailID.IsInitial())

              {

                  emailAcitivtyTo.PartyKey.PartyID.content = employeeMailID;

                  emailActivityInstance.MessageToParty.Create(emailAcitivtyTo);

              }

              else

              {

                  raise Error/Info Messgaes accordingly

              }

              //TextCollectionTextTypeCode 10002 -> Body Text

              var TxtTypeCode = “10002”;

              var emailActivityTxtCollIns = emailActivityInstance.TextCollection.Create();

              emailActivityTextCollText.TypeCode.content = TxtTypeCode;

              var emailActivityTxtCollTxtIns = emailActivityTxtCollIns.Text.Create(emailActivityTextCollText);

             

              //To Display the Message Note

                   

                  emailActivityTextCollTextTextCont.Text.content = “Dear Recipient,” + “\n \n” +

                  “Text Needed “;

              }

              var emailActTxtCollTxtTxtCont = emailActivityTxtCollTxtIns.TextContent.Create(emailActivityTextCollTextTextCont);

              //If Instance is Set then Send the mail

              if (emailActivityInstance.IsSet())

              {

                  emailActivityInstance.Send();

              }

          Please try this and this should work.

          Regards

          Hanu

          (0) 
          1. San Ka Ran

            Hi hanumanth, very  much happy to see your reply. Yep I got an answer. That’s not a matter.  A mail has been triggered successfully. But I need to specify my ‘From address’ as like ‘To addres’ in my coding. I think, in your script, ‘from address’ is static, which ll take service agent mail Id. In above coding, yu declared ‘var employeeAdminMailID’. But whr did you use it! Kindly suggest any script is there to specify From address in scripting?

            (0) 
            1. Hanumath K

              Hi Sankaran,

              // Email: Organizer party – mandatory

              if (! emailActivityInstance.MessageFromParty.IsSet())

              {

                emailAcitivtyTo.PartyKey.PartyID.content = “Sender Email as required”;

              emailActivityInstance.MessageFromParty.Create(elEmailParty);

              }

              Hope this should work

              Regards

              Hanu

              (0) 
  2. San Ka Ran

    Hi,

    How to attach, html tags in message content. I planned to send attractive mail to the user. That’s why I tried with HTML tags. I have normally typed html tags within double codes in msg content variable. But it will print as it is, in email . Anyone help me to send an email with HTML tags. Thanks!

    (0) 
  3. Deepthi Manjunath

    Hi,

    I have added the above script in the ‘BeforeSave’ of a custom BO, which has a web service.  When I call this web service, I expected the script will send an email.  However, I am getting this error in Dump Analysis:

    08:29:29 _1000015 No access possible via a ‘NULL’ data reference. Y00RKLIIY_ /Y00RKLIIY_MAIN/SRC/ErrorHandlingBO-Root-Event-BeforeSave.absl 63 40

    Line no. where the above error is occurring is at:

    instEmail.MessageToParty.Create(elEmailParty);

    When calling the web service itself, it throws the below error:

             <env:Reason>

                <env:Text xml:lang=”en”>RABAX occurred on server side</env:Text>

             </env:Reason>

             <env:Detail>

                <sap:Rabax xmlns:sap=”http://www.sap.com/webas/710/soap/runtime/abap/fault/generic“>

                   <SYDATUM>20160906</SYDATUM>

                   <SYUZEIT>072928</SYUZEIT>

                   <ERRORCODE>DATREF_NOT_ASSIGNED</ERRORCODE>

                </sap:Rabax>

             </env:Detail>

    Can you please advise what I am doing wrong here, I have copy/pasted the above code?

    Thanks in advance,

    Deepthi

    (0) 
  4. SRI HARI

    Hi All,

    Since the EmailActivity is now deprecated, I am trying to make use of Activity BO to perform send mail, but could not achieve the same. i have these points unanswered:

    1. Without creating instance in Activity can I send the mail when Outlook is not configured?
    2. In Activity BO, Party.EmailURI is read only what can be done to specify the sender?

    Please guide.

    Thanks,

    Sri

    (0) 
    1. Melvin Hidalgo Post author

       

      SRI,

      Yes this guide is now deprecated, however using the Platinum Engineering seems to be a new function and looks pretty straight forward for me, I haven’t yet used it, but as soon as I do I’ll update it here.

      I’m attaching a screenshot of the function itself:

      (1) 

Leave a Reply