How can I send an email in the SAPUI5 Hybrid App? Advance SAPUI5 – 3.

One of the standard requirements from R/2 to the world of SAPUI5 apps today is the ability to send emails. Occasionally, we may be required to send emails including attachments or special typefaces.

This tutorial will teach us how to send attachments along with emails utilizing a mobile client and an API.

A) Mobile Client API to send emails in SAPUI5 App
The first thing to do is make a Cordova app. In the command prompt, or cmd, type:

“cordova create email com.email email”
Include the Android operating system by using:

“cordova platform add android”
Put the API Plugin in place.

“cordova plugin add cordova-plugin-email-composer@0.8.15”

Demo: To send an email using the Gmail app, perform the following function:

cordova.plugins.email.addAlias('gmail', 'com.google.android.gm');
cordova.plugins.email.open({
 app: 'gmail',
 to:      'sagarXXXX@gmail.com',
 subject: 'Greetings',
 body:    'How are you? Dummy mail from    …'});

Output:

Emails can now be sent at a high level. Can you, however, upload attachments?

B) SAPUI5 App: Attachment Sending Instructions

Attachments are a little tricky to send. But do not worry, Sagar is here to come to your rescue.Please follow the guidelines below:

<u:Fileuploader  id="fileUploader"/>
var oView = this.getView();
var oFileUploader = oView.byId("fileUploader");
var oFile = oFileUploader.oFileUpload.files[0];
var FR = new FileReader();
var base64;
FR.onload = function(e) {
base64 = e.target.result;
//var oMime = base64.split(";")[0].split(":")[1]
var b = base64.split(",")[1];
var a = base64.split(",")[0].split(":")[1].split(";")[1]+":"+oFile.name+"//";
base64 = a+b;
cordova.plugins.email.addAlias('gmail', 'com.google.android.gm');
cordova.plugins.email.open({
app: 'gmail',
to: 'sagarXXXX@gmail.com',
subject: 'Greetings',
body: 'How are you? Dummy mail from …',
attachments: [base64]
});
};
FR.readAsDataURL(oFile);

Did you follow every step and method listed above?

Be not discouraged. This is an advanced topic, as we all know. As a result, we have attempted to reiterate the instructions below:

Step 1: On Windows, click the “cmd” command.

Step 2: Type “Cordova create email com.email email” on the command line.

Step 3: Add the Android platform by moving to the directory.

cmd "cd email" cmd "cordova platform add android"

Step 4: Use CMD to add the plugin.

“cordova plugin add cordova-plugin-email-composer@0.8.15”

Step 5: Add the lines below to index.html and put your example email app under the WWW folder.

Step 6: Extract the controller and view from the provided zip file.

Step7: Type “Cordova build” and “Cordova run” into the command line.

We have completed our development at last. Let’s browse and submit a file attachment for the Gmail application now.

Note: Since I added Gmail as an alias, Gmail is being used for mailing.

Time to test the App. Hit “Upload” on the SAPUI5 as shown above…. Wola 

To many of you, this may be a topic of advanced interest. Moreover, you might not require it frequently. However, you would undoubtedly encounter this requirement in your projects tomorrow, if not today. At that point, you can return, consult this post, and express your gratitude to us.


you may be interested in this blog here :-

How to find BAdIs ?

Oracle database structure diagram

Boosting Customer Service with Salesforce and SharePoint Integration

  • Related Posts

    BAPI_ALM_ORDER_MAINTAIN terminates with the runtime error MESSAGE_TYPE_X

    Let’s know BAPI_ALM_ORDER_MAINTAIN terminates with the runtime error MESSAGE_TYPE_X in depth. Assuming that you experience a runtime dump with MESSAGE_TYPE_X (CO 888) while referring to BAPI as “BAPI_ALM_ORDER_MAINTAIN”, then, at…

    Sales Office Data … Can you change it even if config does not allow?

    Your business needs to change/right the Business Office information, regardless of whether it isn’t permitted in standard change mode in exchange IW32. See the screen capture, it is incapacitated. Sales…

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    You Missed

    BAPI_ALM_ORDER_MAINTAIN terminates with the runtime error MESSAGE_TYPE_X

    • By Varad
    • April 16, 2025
    • 13 views
    BAPI_ALM_ORDER_MAINTAIN terminates with the runtime error MESSAGE_TYPE_X

    Sales Office Data … Can you change it even if config does not allow?

    • By Varad
    • April 15, 2025
    • 22 views
    Sales Office Data … Can you change it even if config does not allow?

    PO re-price issue in BAPI_PO_CHANGE

    • By Varad
    • April 14, 2025
    • 28 views
    PO re-price issue in BAPI_PO_CHANGE

    Efficient way to retrieve Open Sales Order using FM SD_SELECT_SALES_DOCUMENTS

    • By Varad
    • April 13, 2025
    • 34 views
    Efficient way to retrieve Open Sales Order using FM SD_SELECT_SALES_DOCUMENTS

    ISU – 6 – Bankruptcy Overview and Write-Off Process using BAPI_CTRACDOCUMENT_WRITEOFF

    • By Varad
    • April 12, 2025
    • 32 views
    ISU – 6 – Bankruptcy Overview and Write-Off Process using BAPI_CTRACDOCUMENT_WRITEOFF

    Get Latitude and Longitude of any place using Google Map API in SAP

    • By Varad
    • April 11, 2025
    • 31 views
    Get Latitude and Longitude of any place using Google Map API in SAP