How do I write a Java program to send a custom notification email via Agile PLM?

How do I write a Java program to send a custom notification email via Agile PLM?
I am new to Java but not new to Agile PLM as a regular user.  My first time scripting with it.
Thanks in Advance!

No Files Were Attached
Galactus3000 Agile User Asked on November 29, 2018 in IT and Networking.
Add Comment
2 Answer(s)
Best answer

Hi Galactus3000,

This is how i would suggest you to proceed. Please bear with me if some of the details seems elementary.  You can use this code and test it or google up sample code and integrate in your existing solutions be it PX or SDK based utilities.

1. Step 1 : Open your Project you have setup in your IDE(in my case it is Eclipse) and add external jar in build path of your project. In my case i am using  “mail.jar”. 
2. Scenario : Let’s say i have to sent a mail to my Change analyst after certain activity is completed in Agile.  Let’s say the mail id of my change analyst is

// Making a call to my method sending mail by passing following parameters
String msgBody=
“<b> Please Note: </b> “+ “This is sample mail”;
String msg  =
“Demo Mail”;
“You can enter your mail server detail here”; //e.g.
“” //You can configure a mail id specific for the purpose. The last parameter i have set as blank which you can use to p

//Calling My Sample Mail Method

sendMail(mailServer, mailFrom, ““, msgSubject, msgBody, “”);

//body of mail looks like this for me

    public static boolean sendMail(String mailServer, String from, String to, String title, String body,
            String fileAttachment) {

        // create some properties and get the default Session
        Properties props = new Properties();
        props.put(“”, mailServer);
        Session session = Session.getDefaultInstance(props, null);
        try {
            // create a message
            MimeMessage msg = new MimeMessage(session);
            msg.setFrom(new InternetAddress(from));
            InternetAddress[] address = { new InternetAddress(to) };
            msg.setRecipients(Message.RecipientType.TO, address);
            msg.setSentDate(new java.util.Date());
            // create and fill the first message part
            MimeBodyPart mbp1 = new MimeBodyPart();
            mbp1.setContent(body, “text/html”);
            // create and fill the second message part with attachment

            // create the Multipart and its parts to it
            Multipart mp = new MimeMultipart();

            // Test for file attachment = empty string
            if (!fileAttachment.equals(“”)) {
                MimeBodyPart mbp2 = new MimeBodyPart();

                DataSource source = new FileDataSource(fileAttachment);
                mbp2.setDataHandler(new DataHandler(source));
                String value = “”;// remove directory from file name
                value = fileAttachment.substring(3);


            // add the Multipart to the message
            // send the message
        } catch (MessagingException mex) {
            Exception ex = null;
            if ((ex = mex.getNextException()) != null) {
            } // end if
            // err_flag = true;
        } // end try catch
        return true;



Arif Agile Angel Answered on November 29, 2018.
Add Comment


If the email you are trying to send is related to PLM Object information, you can define a custom notification in Agile JavaClient and invoke the notification from Java using APIs.

I am not a developer hence will not be able to provide code snippets.  Please check the SDK Guide.


Sankar Sakthivel Agile Angel Answered on December 1, 2018.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.