Skip to Content
Author's profile photo Alessandro Iannacci

New email functionality for tenants 1502 SP01

In the new 1502 release there will be a new way to send mail, that will enable you to change the sender address as you want!

The emails sent in this way will not be available in the activity->email workcenter, but you can always trace them using a custom development.

Step 1. Create the reuse function


You can always skip this step, even if this is not recommended.

2.PNG

1.PNG

Step 2. (ab)use the reuse function

3.PNG

4.PNG

/wp-content/uploads/2015/02/5_637274.jpg

The highlighted yellow part is mandatory.

The highlighted green part is our reuse function.

Happy mailing 🙂

Assigned Tags

      40 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Jacques-Antoine Ollier
      Jacques-Antoine Ollier

      Thank you very much Alessandro,

      As always, the first on great things!

      Best regards!

      Jacques-Antoine

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Thank you! Always happy to provide something useful 🙂

      Author's profile photo Jacques-Antoine Ollier
      Jacques-Antoine Ollier

      How did you find this new functionality dear Alessandro?

      I passed through the new user guide, nothing seems to mention it, neither in the "What's new" document.

      How do you find all this tips and tricks? 🙂

      Thank you for your attention.

      Best regards.

      Jacques-Antoine

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Good SAP contact 🙂

      Author's profile photo Dhruvin Mehta
      Dhruvin Mehta

      Thanks alessandro! It is fantastic! 🙂

      Author's profile photo Former Member
      Former Member

      Great document....

      Thanks Alessandro for sharing this document.....!!!!!


      Regards,

      Mithun

      Author's profile photo Former Member
      Former Member

      thank you Alessandro,

      could you send us the path (the URL) to download the CLOUD STUDIO 1502 ?

      Best Regards

      Luis

      Author's profile photo Jacques-Antoine Ollier
      Jacques-Antoine Ollier

      Hello,

      I can personally download it since yesterday.

      Installations and Upgrades | SAP Support Portal

      Go to Browse our Download catalog, then SAP Cloud Solutions, then SAP Cloud App Studio 1502.

      Of course it depends on your user access rights.

      Best regards.

      Jacques-Antoine

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Thanks

      Author's profile photo Tom Lennart Behrens
      Tom Lennart Behrens

      It is working fine for me. Thanks for sharing!

      Best regards

      Tom

      Author's profile photo Sander Boers
      Sander Boers

      it would be so great if your code was also available in text instead of pictures.

      wonderful blog though!

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Thanks. contact me via pm i will try to send you an example!

      Author's profile photo Anthony K
      Anthony K

      Hi Alessandro,

      What is "qryCatPhNot"? Could you please tell me which BO or context variable do you use? I can see from the code, it is returning the email template. Thanks a lot

      Author's profile photo Anthony K
      Anthony K

      Hi Alessandro,

      What is "qryCatPhNot_Result"? Could you please tell me which BO or context variable do you use? I can see from the code, it is returning the email template. Thanks a lot

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Hi, no CatPhNot is a BCO with some configurations (recipients based on some settings)

      Author's profile photo Anthony K
      Anthony K

      Hi Alessandro, thanks for the info.

      And how do you create EmailTxt with placeholder &1?

      I am on 1505 but don't see this new functionality in SDK guide. Is there a way to get the uploaded HTML file from Service -> Template? Thanks again

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      There is no standard way. If you want a template you need to create a BCO or a BO, storing your text (with placeholders) and implement a function (for example a reuse function) to get it back, replacing the placeholders.

      Author's profile photo Elena Troanca
      Elena Troanca

      Hi Alessandro,

      Thanks for your helpful info.

      Does this custom email functionality support also HTML format, e.g.:

      var lv_body : XPEString;

      lv_body = "<html><head><meta http-equiv=\"Content-Type\"     content=\"text/html; charset=utf-8\" /><title>Template</title></head><body><b>test</b></body></html>";

      I guess if BodyIsHTML parameter is set as true,then we can insert HTML coding into the body content.

      e.g. SendEmail.SendEmailABSL(recepients, from, subject, body, Attachments, true);

      Thanks and regards,

      Elena

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Hi Elena, should work, but I never tried!

      Author's profile photo Anthony K
      Anthony K

      Hi Elena, HTML format is working. But when I ran a test, it is limited to 255 chars. I guess you just need to concatenate the XPE Strings. Let us know how you go.

      Author's profile photo Christine Toblier
      Christine Toblier

      Hi Alessandro, thank you for your blog post.

      This is very useful.

      Can I ask one more question:

      Can you tell me how i can add an attachment to the mail?

      I created a PDF out of a custom form.

      var docType : GlobalDataTypes:DocumentTypeCode;

      var FormTemplateLanguage = "DE";

      var PDF : BinaryObject; >

      var FormTemplateCode : OutputRequestFormTemplateCode;

      FormTemplateCode.content = "Y3I06KDB_PB634";

      //Code is Form Template Header Code

      PDF = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);

      PDF.mimeCode = "application/pdf"

      The Data Type of this PDF is BinaryObject (BASIS.Global)

      The Function SendMail needs an AttachmentList of Type Attachment (AP.Platinum). Attachment.Binary is of Type Binary(AP.Platinum).

      Do you have an Idea how i can handle this data types and create an attachment out of my formular?

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Hi Christine,

      I never tried but please try like this

      xscn.JPG

      Author's profile photo Christine Toblier
      Christine Toblier

      Hi Alessandro,

      thank you for your answer. I have already tried to to that.

      The problem is, that the function SendWithAttachment takes Attachments of type AP.PlatinumEngineering.Attachment. I don't know how to create an attachment of this datatype.

      I can create a binary of tybe BASIS.Global.Binary.

      AP.PlatinumEngineering.Attachment, just takes binaries of type AP.PlatinumEngineering.Binary.

      I cannot assign the binary from one namespace to the binary form the other namespace.

      Do you know, where I can get more Information about that the PlatiniumEngineering Attachment and how i can create an attachment of that type?

      Kind regards,

      Christine Toblier

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Hi Christine,

      in the following example I tried to assign a binary of type BASIS.Global.Binary (atta) to the binary of type AP.PlatinumEngineering.Attachment (atta3)

      xscn2.JPG

      Author's profile photo Christine Toblier
      Christine Toblier

      I tried that too, but then my Email had no attachment at all. So I thought, that it is of that mismatch. Have you tried to generate an email with that code?

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Not with attachments :\

      Or you can use the old way to send emails. Check in my past blogs

      Author's profile photo Former Member
      Former Member

      Hi Alessandro Iannacci

      I have an attachment created in my custom BO BO_ticket which is of type Binary but now I have created an extension object for service ticket where I have an action Send Email in which I need to read that attachment from my custom BO and then I need to send the same attachment in the email. For send email I am using above blog approach where attachment will be Platinum Engineering attachment

      // create PDF

      var FormTemplateLanguage = "E";

      var FormTemplateCode : OutputRequestFormTemplateCode;

      FormTemplateCode.content = "YE2P6WJ7_PVIQD";

      var pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);

      if (!pdfDocument.content.IsInitial()) {

          Trace.Info("document successfully created");

        Attachment.Binary=pdfDocument.content;

        Attachment.FileName="hello.pdf";

        Attachments.Add(Attachment);

      }

      So here I am not able to read my custom attachment correctly and supply it correctly to

      Attachments.Add(--------)


      Can you please help me on how to read this attachment correctly


      Thanks

      Saruchi

      Author's profile photo Stefan Kiefer
      Stefan Kiefer

      Hi,

      I am writing here as the Author of this function. I got to know this "HTML 255 chars damn thing" from Tom lennart and I plan to improve this in 1511 in the way that you do not need to care of breaks.

      One more thing to the users of the function: The Tenant URL has always to be inside the email otherwise the function will add it. This is to track from which tenant the email is sent from - not to cause SPAM.

      Cheers

      Stefan

      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci
      Blog Post Author

      Hi Stefan happy to see you on SCN!

      Author's profile photo Fred K
      Fred K

      Hi Stefan,

      Can you please give some info for how to use Mail.SendWithAttachment?

      Best Regards

      Fred

      Author's profile photo Fred K
      Fred K

      Hi Stefan,

      I can send the attached file with the following codes.

      Please correct me if there is anything strange in my codes.

      var FormTemplateLanguage = "E";

      var FormTemplateCode : OutputRequestFormTemplateCode;

      FormTemplateCode.content = "TemplateHeaderCode";

      var pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);

      if (!pdfDocument.content.IsInitial()) {

        att.Binary=pdfDocument.content;

        att.FileName="hello.pdf";

        atts.Add(att);

      }

      // function call

      Mail.SendWithAttachment(EmailSubject,EmailBodyTab,EmailFrom,Receipients,true,atts);

      Best Regards

      Fred

      Author's profile photo Stefan Kiefer
      Stefan Kiefer

      Hi Fred,

      You code looks fine.

      I would suggest you sent the email at first without the attachement - if this works - I would try to add the attachments. If the datatype of the attachment matches it should work.

      Best regards,

      Stefan

      Author's profile photo Fred K
      Fred K

      Hi Stefan,

      It works, it works. 🙂 Thanks to you and Alessandro.

      I was just confirming with you.

      Best Regards

      Fred

      Author's profile photo Former Member
      Former Member

      Hi Fred K

      so it was possible for you to send email with attachments using Reuse library. In my requirement also I need to send my custom form as attachments.

      Thanks

      Saruchi

      Author's profile photo Fred K
      Fred K

      Hi Saruchi,

      Yes, i could send with the codes I mentioned.

      Best Regards,

      Fred

      Author's profile photo Former Member
      Former Member

      Hi Fred K

      Did you faced any issue with attachment AP.PlatinumEngineering.Attachment. Do you used the conversion as suggested by Alessandro for pdf attachment?

      Author's profile photo Fred K
      Fred K

      Hi Saruchi,

      What kind of conversion do you mean?

      I created attachment from PDF template.

      Here is the complete code for your reference:

      import ABSL;

      import AP.PlatinumEngineering as Platinum;

      import DocumentServices.Global;

      import AP.Common.GDT;

      var Receipients :EmailRecepientDataTable;

      var EmailReceipient :EmailRecepientData;

      var SendFromURL :XPEString;

      var EmailBodyTab :XPEStringTab;

      var instance :EmailRecepientData;

      var EmailSubject :XPEString;

      var EmailFrom :EmailURI;

      var atts:collectionof Platinum: Attachment;

      var att:Platinum: Attachment;

      ///////////////////////////////////////////////////////////////

      var ATTACHMENT_TYPE_DOCUMENT : DocumentTypeCode;

      ATTACHMENT_TYPE_DOCUMENT.content = "10001";

      // create PDF

      var FormTemplateLanguage = "E";

      var FormTemplateCode : OutputRequestFormTemplateCode;

      FormTemplateCode.content = "FormTemplateHeaderCode";

      var pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);

      if (!pdfDocument.content.IsInitial()) {

          Trace.Info("document successfully created");

        att.Binary=pdfDocument.content;

        att.FileName="hello.pdf";

        atts.Add(att);

      }

      ///////////////////////////////////////////////////////////////

      //1

      EmailSubject=this.Subject;

      //2

      foreach(var t in this.ItemTextCollection.Text){

        EmailBodyTab.XPEString.Add(t.TextContent.Text.content);

      }

      //3

      EmailFrom.content=this.MailFrom;

      foreach(var receipient in this.Recipients){

        EmailReceipient.EmailRecepientTypeCode=receipient.EmailRecepientTypeCode;

        EmailReceipient.EmailUri.content=receipient.EmailRecepientMailAdd;

        Receipients.EmailData.Add(EmailReceipient);

      }

      if(!Receipients.IsInitial()){

        Mail.SendWithAttachment(EmailSubject,EmailBodyTab,EmailFrom,Receipients,true,atts);

      }

      Best Regards,

      Fred

      Author's profile photo Former Member
      Former Member

      Hi

      This statement is failing in my scenario , though I am passing the correct FormTemplateCode and language as E

      var pdfDocument = OutputManagementUtilities.GetPDF(this, FormTemplateCode, FormTemplateLanguage);

      Author's profile photo Danny Lipkovski
      Danny Lipkovski

      Hi Stefan,

      we are using the mentioned function but we are wondering that the subject in the sent mail is cut-off after 50 digits.
      Is it true that the subject can have a maximum of 50 digits or is there any workaround to have more than 50 digits?

      Regards

       

      Danny

      Author's profile photo Former Member
      Former Member

      Thanks for this valuable blog.