What do you mean by completed normally ?  If it  throws an exception it will do the 'Cleanup' routine and finish .. Maybe it would be better to log a message of the caught exception before the CleanUp routine and see if it produces anything (so System.out.println(e1) ) .. 


On Monday, 17 November 2025 at 18:23:18 GMT, Versfelt, Charles via JAVA400-L <java400-l@xxxxxxxxxxxxxxxxxx> wrote:

Hi,
I'm fairly inexperienced in java, I'm mainly an old-school RPG programmer.
We have several Java programs that send e-mails, some with and some without attachments, using Apache commons.
I'm somewhat familiar with the programs.  Our IBMi is on java version "1.6.0"

We're switching our e-mail to office 365.
I've gone through the same change with a number of Visual Basic programs, and now I'm trying to address the IBMi Java programs.

The changes I had to make in my  Visual Basic programs are these:
1. The host has to change to smtp.office365.com
2. SSL has to be enabled.
3. The port used has to be 587.
4. I have to force TSL 1.2 security level.
In Visual Basic, to force TSL 1.2, I had to use command ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12

From the searching I did online, I found some websites talking about sending office 365 e-mails in Java, but not a lot specific to Apache Commons.
As I said, I don't want to rewrite the programs if I can avoid it.

As far as I can tell from what I saw online, if all I need is what I changed in my VB.net programs, I can change these in my Apache Commons Java E-mail programs like this:
1. email.setHostName("smtp.office365.com");
2. email.setSSLOnConnect(true);
3. email.setSmtpPort(587);

4. System.setProperty("mail.transport.protocol", "smtps");
System.setProperty("mail.smtps.ssl.protocols", "TLSv1.2");

So my program looks like this, passwords and e-mails masked.

HtmlEmail email = new HtmlEmail ();

//email.setHostName("exchange.postoffice.net");
System.setProperty("mail.transport.protocol", "smtps");
System.setProperty("mail.smtps.ssl.protocols", "TLSv1.2");
email.setHostName("smtp.office365.com");
email.setSmtpPort(587);
email.setSSLOnConnect(true);
(everything below is original)
try {
email.setFrom("xxx@xxxxxxx", "Me");
email.setAuthenticator(new DefaultAuthenticator("xxx@xxxxxxx" "xxx"));
} catch (EmailException e1) {
CleanUp();
}
When I test this program from the command line RUNJVA, the program says Java program completed, but no e-mail arrives.
As far as I can tell it's not encountering any errors.  It's just not sending an e-mail.
Am I missing something?

Thanks for your help.
Charles Versfelt



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.