is there a way to send e-mail with the Windows default Email Provider?
If a button is pressed, the standard email provider should open automatically so that you can send an email.
I tried this Java class, but somehow it doesn't work or I'm doing something wrong.
B4X:
Sub Process_Globals
Private NativeMe As JavaObject
End Sub
Sub AppStart (Form1 As Form, Args() As String)
...
NativeMe = Me
...
End Sub
Sub GetDefaultEMailClient_Click()
NativeMe.InitializeNewInstance("RunningDefaultMailClient", Null)
NativeMe.RunMethod("client", Array("123456@gmail.com"))
End Sub
#if Java
package org.kodejava.example.awt;
import java.awt.*;
import java.io.IOException;
import java.net.URI;
Public class RunningDefaultMailClient {
Public static void Main(String[] args) {
// Get an instance of Desktop. If the platform doesn't support Desktop API an
// UnsupportedOperationException will be thrown.
Desktop desktop = Desktop.getDesktop();
Try {
// Open user-default mail client application.
desktop.mail();
} Catch (IOException e) {
e.printStackTrace();
}
Try {
// Open user-default mail client with the email message fields information.
String message = "mailto:dummy@example.com?cc=test@example.com&subject=First%20Email";
URI uri = URI.create(message);
desktop.mail(uri);
} Catch (IOException e) {
e.printStackTrace();
}
}
}
#End If
This is how I changed the java part.
Call it with NativeMe.RunMethod("sendEmail",null)
Java:
#if java
import java.awt.*;
import java.io.IOException;
import java.net.URI;
public static void sendEmail() {
// Get an instance of Desktop. If the platform doesn't support Desktop API an
// UnsupportedOperationException will be thrown.
Desktop desktop = Desktop.getDesktop();
if (desktop==null) System.out.println("desktop failed");
try {
// Open user-default mail client with the email message fields information.
String message = "mailto:dummy@example.com?cc=test@example.com&subject=First%20Email&body=hello%20there";
URI uri = URI.create(message);
desktop.mail(uri);
} catch (IOException e) {
e.printStackTrace();
}
}
#End If
what if there is no mail client installed/configured? most people use gmail webmail these days.
you could use vbscript but then you need to rely on an smtp relay and port 25 that needs to be open on local & router firewalls.
a better option would be posting to a server and mail it from there then you're always sure that mails will be processed and you can add your own logging for it.
what if there is no mail client installed/configured? most people use gmail webmail these days.
you could use vbscript but then you need to rely on an smtp relay and port 25 that needs to be open on local & router firewalls.
a better option would be posting to a server and mail it from there then you're always sure that mails will be processed and you can add your own logging for it.
Hi @sorex ,
my problem is that i still don't know what to do.
The customer should be able to send 2 different emails:
1. an email with a license request to me
2. Send the data you have created with my application, by e-mail or otherwise.
Thanks Erel, but I'm trying to organize the whole thing now without email.
I simply give my users the necessary information and they should send me an email with their default program.
If that doesn't work, then I have to think of something else.
As written earlier you could just add a contact form to you program and post it to some website and use php to send the mail to you.
Then you don't need to rely on smtp servers and the required port 25 which is usually closed in business envirenments exept for the local mail server.
As written earlier you could just add a contact form to you program and post it to some website and use php to send the mail to you.
Then you don't need to rely on smtp servers and the required port 25 which is usually closed in business envirenments exept for the local mail server.