2

I am working on some application, which will be running on offline pc. This application should prepare some email to the file (txt, eml, msg,..). The file should contain the subject, the text and ideally also an attachment or path to the attachment.

This file is then copied via usb cable or bluetooth to the android device with internet connection, the email shall be then sent as easy as possible - my idea is just open the file with email client and click send?

Is there some solution for such a use case?

(Please don't suggest me to create a hotspot and send the directly from the pc, this is not possible in this case.)

Meloun
  • 13,601
  • 17
  • 64
  • 93
  • It might be me but your question is confusing. Maybe try rewording? – spartygw Jul 16 '21 at 20:49
  • What if the email has an attachment which is in PC and the path specified is from PC Example C:\..\Desktop in the file you are mentioning (txt, eml etc). Then how that file will be referenced in Android ? – Swaminathan V Jul 18 '21 at 04:59
  • Have you created your Android app as well to do this email sending task? – pankaj yadav Jul 22 '21 at 04:02

3 Answers3

0

I can imagine two different ways for doing this, 1- using intent 2- using web service; First step for both approaches is extracting data from file. now assume that you want to use intent. for doing this you can use bellow codes:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@emailaddress.com");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.");
startActivity(Intent.createChooser(intent, "Send Email"));

another way is creating a web service for sending email. for doing this you can refer to https://stackoverflow.com/a/6270987/12500284; then you should call this API through android app and passing the data to it. The advantage of this approach is sending email without involving user for it.

Alireza Barakati
  • 1,016
  • 2
  • 9
  • 23
0

Save the Outlook message as a Message File File - Save

Then just put it on your phone and open it?

I am confused on this one, is this to force a phone send an email from the PC, are you requesting that we code a worm for you?

Or are you manually opening the file because that is litterally it, just do that.

Xyloz Quin
  • 178
  • 4
0

Serial Ports

Please can you edit the question and specify a coding language for the offline pc.

Assuming you are coding in c# though, you can use the SerialPort class and SerialPortObject from System.IO.Ports to send data over USB.

When I used it, mine looked something like this:

using System.IO.Ports;

string[] ports = SerialPort.GetPortNames();

try
{
    SerialPortObject.PortName = ports[0].ToString();
    SerialPortObject.Open();
}
catch (Exception ex)
{                
    Console.WriteLine(ex.Message);
}

SerialPortObject.Write("Hello World");
string response = SerialPortObject.ReadLine();

NOTE: By using ports[0] I am attempting to connect to the first serial port found. Also, you could send the data via JSON to make sure its all in one long string.

As said by Microsoft though:

If there are too many bytes in the output buffer and Handshake is set to XOnXOff then the SerialPort object may raise a TimeoutException while it waits for the device to be ready to accept more data.

Sorry if this isn't what you need, I just don't really understand the question.

Leo
  • 101
  • 8