Emailing on a mobile device

Looking to develop a mobile application that can send emails with both single and multiple attachments across Android and iOS platforms.

Initially attempted using JavaScript on android, but seeking a solution that can work seamlessly on both android and ios.

<!DOCTYPE html>
<html>
<head>
<script>
function sendMail() {
    var link = "mailto:<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6a070f2a0f120b071a060f44090507">[email protected]</a>"
             + "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="744b171749190d37371510100611070734110c15190418115a171b19">[email protected]</a>"
             + "&subject=" + escape("This is my subject")
             + "&body=" + escape(document.getElementById('myText').value)
    ;

    window.location.href = link;
}
</script>
</head>
<body>
<button onclick="sendMail(); return false">Send</button>
</body>
</html>

The current solution opens Outlook 2000 which is not ideal for mobile phones. Looking for a way to open the default Gmail app on the phone, with the sender as the logged-in user and dynamically add the receiver's id.

Also explored Java but encountered limitations when it comes to sending attachments from the client-side.

If you have any suggestions or solutions that could meet these requirements, I would greatly appreciate it. Thank you!

Answer №1

To incorporate the Java-Mail jar (JMAPI), you can generate a temporary email file (.eml) in which attachment, subject, recipient, and body are included using MimeMessage. By utilizing Runtime.getRuntime.exec(), this .eml file can be opened to launch the default email client, with the sender being the authenticated user.

It's important to note that the "mailto:" URI cannot accommodate attachments since support for attachments has been eliminated from mailto functionality.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Having trouble setting up the next-auth login page and experiencing issues with the getProviders() function

Greetings to all fellow web developers, I am currently working on a Next.js application that utilizes next-auth for user authentication. I have set up the [...nextauth].js file in the "pages/api/auth" directory and a signin.js file in the "pages/auth/" di ...

Is it possible to create a fixed position shader background in three.js?

Trying to incorporate a pixel shader as a background in three.js without affecting the camera rotation with OrbitControls. Most implementations use a 2D plane, but I want it to remain fixed in the scene. Is there a way to achieve this with two separate can ...

Using JSON to import categorical data from SQL into C3.js

I am currently working on creating dynamic column graphs in MVC by utilizing C3 Charts. Although I have successfully retrieved data from the database using AJAX/JSON, I am facing challenges in binding the X-Axis categories along with the Y-Axis coordinates ...

What is the best way to incorporate this interaction model using jQuery?

I am exploring the possibility of implementing a unique interaction model using jQuery. If a user is typing on a page and enters three exclamation points in a row ("!!!"), I want jQuery to take action. Once three exclamation points are detected, I wa ...

Oops! The Python TextBlob library couldn't locate the resource at 'tokenizers/punkt/english.pickle'

A similar issue was encountered by someone else, but they were able to solve it by downloading the necessary packages. I have already downloaded the packages, yet I am still experiencing the error. Oddly enough, I can run the code in the terminal without ...

Leveraging variables within a Regex query in MongoDB using JavaScript

I am trying to locate a specific row in MongoDB using OR and I need to include a JavaScript variable inside the regex. However, when I do this, the query returns null. By replacing /${oriFilename}/ with my file name like "CB0123456781_20210604165222", the ...

"Encountering an issue with ASP.NET MVC and Angular when making an AJAX call with multiple parameters, the HttpPostedFileBase

When sending an object and a file from my Angular service, the following code snippet is executed: $scope.addProject = function () { { var project = {}; project["Id"] = $scope.Id; project["ProjectCode"] = $scop ...

What is the reason that setState does not update the value of the "editing" key to true?

The edit feature does not switch the state of editing to true. I am at a loss for what to do: class Note extends React.Component { constructor (props) { super(props) this.state = { editing: false } } /**edit() { this.setState = ...

Exploring the contents of an Ajax response

Just starting out with jquery & Ajax. I've created a php file that contains jquery code to load content from another php file when a date is selected. $("#datepicker3").change(function(){ $.ajax({ type: "POST", ...

Is there a way to access data from a database using ajax and php?

I am attempting to verify if a field exists in the database before submitting a form. To achieve this, I have added the keyup event to the field to fetch data from the db using ajax. Below is the code snippet that I have added where the form is: $(docum ...

Getting user information in nuxt/auth: A simple guide

I need help accessing data stored in local storage using the testData() function. When I try, my console prints out {ob: Observer}. The data is set inside the login() function and I can see it in my browser. Being new to front-end development, any assista ...

Encountering challenges during the transition from Jest@26 to Jest@27

I'm currently in the process of upgrading Jest from version 26 to 27 for my Next.js 13 project, but I've encountered an error when running tests after the update. The error message is as follows: FAIL src/__tests__/app.test.tsx ● Test suite ...

Imitate a keypress within a hidden web browser component using C#

Currently, I am engaged in a project that requires me to navigate a webpage and gather information about products, prices, etc. using the webbrowser object in .NET 3.5. The challenge arises because the page contains fields with an ajax suggest script, mak ...

"Troubleshooting the issue of nested jQuery Ajax requests failing to execute properly

UPDATE: I'm getting an error saying that my li tag is considered an illegal token. I'm unsure how to resolve this issue as I believed I was appending it within a ul tag I'm tasked with fetching a JSON array of public Github repositories and ...

Saving file with HTML download button results in only HTML document being saved

I am attempting to include a "download file" button on my gatsby website as shown below: <a href="../../images/project-logos/placeholder-company-logo.png" download="test" className="responsive-square project-logo" > <img sr ...

Should data be sent via ajax to the server before reloading the page to view the results, or is it more efficient to update the DOM using JavaScript?

Hello there, I am working on a Django (3.1) site that has some interactive features where users can add, edit, and delete comments using html/javascript code. Currently, when a user performs one of these actions, the script sends the data to the server vi ...

Pug does not have access to computed properties within the dynamic class attribute of a Vue component

After attempting to dynamically toggle the className based on computed property and encountering issues in Pug, I found that manually setting 'true' to a className was the solution. Even after trying to reassign the computed property to a Pug var ...

Redirecting with Express js when the cookie is not found

I successfully integrated Facebook login using Passport-js and also set up Cookie-strategy for traditional username/password login on my Express-js backend with a React front-end. The backend and frontend are hosted on separate servers and domains (backend ...

Entering data into a webpage and retrieving the result from a designated cell in a Google Sheets document

Currently, I am in the process of developing a school platform and I am looking to incorporate a functionality that allows students to easily check the number of "passport" points they have earned. I envision having an input field along with a button that ...

Transferring the state from a parent component to a child function

I'm having trouble passing a state from a component to a function. I was able to pass the state from Home to ListHome, but I'm struggling to continue passing it to a function within ListHome (Slider) because it's a function. Even after revi ...