-3

Is there a way to write a simple email with Kotlin? I just want to send some Text. I already tried commons email but i can not import it... Is there also a way without Java Code?

Thanks

mxrvin
  • 11
  • 5
  • You can use any Java library, such as Commons Email, in Kotlin and not have to write any Java code. Maybe you can show us what you tried so we can correct you on how to import it. – Tenfour04 Mar 15 '21 at 17:00
  • Hello! I tried to import the commons.mail libary but i cannot import the org.apache.commons.mail everytime i get an error with the .mail line... – mxrvin Mar 15 '21 at 17:13
  • That's not enough to go on. We don't know how you manage your project (native IntelliJ IDEA project, Gradle or Maven based, etc) and how you imported the library jar. – Tenfour04 Mar 15 '21 at 17:32

1 Answers1

1

Kotlin is just a language; it's up to the platform to provide that sort of functionality.

If you're running on the JVM, then there are many libraries which can do this for you.  The most standard is probably javax.mail; questions such as this one show how to call it from Java, but you can access it from Kotlin in much the same way.

If you're running on Android, then that probably has its own library you can use.  Similarly on JavaScript, there may be APIs you can use.  (I don't know anything about those platforms, I'm afraid.)

If you're running Kotlin Native, then you may have a native program you can call.

Finally, many platforms have a stand-alone program you could run, such as the mailx program on macOS and Unix.  See this question for ways to run an external program from Kotlin; though you'd need to check that whichever program you wanted was available on the machine (or install it yourself).

gidds
  • 16,558
  • 2
  • 19
  • 26