Sample Send Email Java code in OIM.

Hi All,
Can anybody please tell me the sample code to send an email when ever the new user created in the OIM an email has to be sent to that user's email ID(specified while user registration).
Thanks in Advance.
Siva Pokuri.

Hi JMD,
Thanks for your quick response.
I have written the same code what you specified here and i deployed in JavaTasks folder of OIM server.
And i have created Entity Adapter for this code as well.
I have assigned this adapter to user for in Data Object Manager as a post insert task.
And finally when im trying to create the user in OIM the task was triggering but its giving the NullPointer Exception.
I donno where i have done the mis configuration. Is there anythign that im missing??
Please helpme out.
Thanks & Regards,
Siva Pokuri.

Similar Messages

  • Java code in OIM

    Hello All,
    I am trying to run the below java code via OIM.Its a simple code for testing and I will later modify it.
    After reading the threads on forum I created the BI outside the main class.
    After adding the jar..I when I am adding a adptr task and selecting this jar it gives me an "error server could not load class"
    Please letme know If I am missing any thing in the code?
    Also once a code is created are there some predefined steps to make that functional?
    The code is working fine for me when test in eclipse
    package oimtest;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    public class myFirst {
    public void testmethod() throws SQLException, ClassNotFoundException
    Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@//localhost:1521/orcl", "oimusr", "*****");//orcl is sid,oimuser is the username
    Statement stmt = conn.createStatement();
    ResultSet rset = stmt.executeQuery("MY QUERY HERE'");
    while (rset.next())
    System.out.println(rset.getString(1));
    conn.close();
    }

    I am using my oim on 1.5 and compiling on the same version
    2010-04-08 23:33:28,000 DEBUG [org.jboss.proxy.ejb.ProxyFactory] seting invoker proxy binding for stateful session: stateful-rmi-invoker
    *2010-04-08 23:33:28,015 ERROR [org.jboss.ejb.plugins.LogInterceptor] Unexpected Error in method: public abstract boolean com.thortech.xl.ejb.interfaces.tcADP.introspectAPI(java.lang.String,java.lang.String,java.lang.String,boolean) throws java.rmi.RemoteException*java.lang.NoClassDefFoundError: dbcontest (wrong name: oimtest/myFirst)
         at java.lang.ClassLoader.defineClass1(Native Method)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
         at java.lang.ClassLoader.defineClass(ClassLoader.java:465)
         at com.thortech.xl.dataobj.tcADPClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
         at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
         at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
         at java.lang.Class.forName0(Native Method)
    Edited by: Shalini Bhasin on Apr 9, 2010 12:17 AM

  • Error while sending Email through Java Code in OIM

    Hi All,
    I have created a java code using tcEmailNotificationUtil, and integrated the same with the adapter.
    I am triggering this adapter when an approval process gets completed.
    As soon as the approval process gets completed my email task is triggering but the task is getting rejected.
    I have checked my system configuration for mail server settings.Everything seems working fine.
    Can you please help me in this issue how to debug?
    Thanks in advance.

    Hi,
    Here is my log file:
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/insertTaskHistory left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/run entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/execute entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/initialize entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getAttribute entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getAttribute left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getUtility entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/getUtility left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.ACCOUNTMANAGEMENT] - Class/Method: tcUtilityFactory/getRemoteUtility - Data: moUtil - Value: Thor.API.Operations.tcAuditOperationsClient
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/initialize left.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/processAllByIdentifier entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,099,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,100,[XELLERATE.DATABASE] - select A.* from (select aud_jms_key, aud_class, identifier from aud_jms order by aud_jms_key) A where rownum <= ?
    INFO,25 Apr 2011 10:40:00,101,[XELLERATE.PERFORMANCE] - Query: DB: 1, LOAD: 0, TOTAL: 1
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isStopped left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: ReIssueAuditMessage/execute left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/run left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isSuccess entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SCHEDULER.TASK] - Class/Method: SchedulerBaseTask/isSuccess left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: SchedulerTaskLocater /removeLocalTask entered.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: SchedulerTaskLocater /removeLocalTask left.
    DEBUG,25 Apr 2011 10:40:00,102,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateStatusToInactive entered.
    DEBUG,25 Apr 2011 10:40:00,104,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateStatusToInactive left.
    DEBUG,25 Apr 2011 10:40:00,104,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateTaskHistory entered.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/updateTaskHistory left.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Clearing Security Associations with thread executing Scheduled task
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/run left.
    DEBUG,25 Apr 2011 10:40:00,106,[XELLERATE.SERVER] - Class/Method: QuartzWrapper/execute left.
    and I just wanted to ensure that my coding part is also fine.
    Posting the code even:
    tcDataProvider ioDatabase = new tcDataBaseClient();
    tcEmailNotificationUtil sendMail = new tcEmailNotificationUtil(ioDatabase);
    sendMail.setBody("Sample Message");
    sendMail.setSubject("subject");
    sendMail.setFromAddress("fromemailaddress");
    sendMail.sendEmail("recepient");
    Thanks in Advance.

  • Send Email Java Error

    Dears,
    I have a database package to send an email to an employee, whole package working well except the send mail part, the error raised from java code i used says ( Can't send command to SMTP host No trusted certificate found).
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SendMail {
       // Sender, Recipient, CCRecipient, and BccRecipient are
       // commaseparated lists of addresses.
       // Body can span multiple CR/LF-separated lines.
       // Attachments is a ///-separated list of file names.
       public static int Send(String SMTPServer,
                              String Sender,
                              String Recipient,
                              String CcRecipient,
                              String BccRecipient,
                              String Subject,
                              String Body,
                              String ErrorMessage[],
                              String Attachments) {
          // Error status
          int ErrorStatus = 0;
          // Create some properties and get the default Session
          Properties props = System.getProperties();
          //props.put("MyMailingServer", SMTPServer);
          props.put("mail.smtp.starttls.enable", "false");
         // mail.smtp.starttls.enable=false;
      props.put("mail.smtp.host", SMTPServer);
      props.put("mail.smtp.port", 25);
      props.put("mail.smtp.auth", "true");
      props.put("mail.smtp.auth", "user");
      props.put("mail.smtp.auth", "password");
          Session session = Session.getDefaultInstance(props, null);
          try {
             // Create a message
             MimeMessage msg = new MimeMessage(session);
             // extracts the senders and adds them to the message
             // Sender is a comma-separated list of e-mail addresses as per RFC822
                InternetAddress[] TheAddresses = InternetAddress.parse(Sender);
                msg.addFrom(TheAddresses);
             // Extract the recipients and assign them to the message.
             // Recipient is a comma-separated list of e-mail addresses as per RFC822.
                InternetAddress[] TheAddresses = InternetAddress.parse(Recipient);
                msg.addRecipients(Message.RecipientType.TO,TheAddresses);
             // Extract the Cc-recipients and assign them to the message.
             // CcRecipient is a comma-separated list of e-mail addresses as per RFC822.
             if (null != CcRecipient) {
                InternetAddress[] TheAddresses = InternetAddress.parse(CcRecipient);
                msg.addRecipients(Message.RecipientType.CC,TheAddresses);
             // Extract the Bcc-recipients and assign them to the message.
             // BccRecipient is a comma-separated list of e-mail addresses as per RFC822.
             if (null != BccRecipient) {
                InternetAddress[] TheAddresses = InternetAddress.parse(BccRecipient);
                msg.addRecipients(Message.RecipientType.BCC,TheAddresses);
             // Subject field
             msg.setSubject(Subject);
             // Create the Multipart to be added the parts to
             Multipart mp = new MimeMultipart();
             // Create and fill the first message part
                MimeBodyPart mbp = new MimeBodyPart();
                mbp.setText(Body);
                // Attach the part to the multipart
                mp.addBodyPart(mbp);
             // Attach the files to the message
             if (null != Attachments) {
                int StartIndex = 0, PosIndex = 0;
                while (-1 != (PosIndex = Attachments.indexOf("///",StartIndex))) {
                   // Create and fill other message parts;
                   MimeBodyPart mbp = new MimeBodyPart();
                   FileDataSource fds =
                   new FileDataSource(Attachments.substring(StartIndex,PosIndex));
                   mbp.setDataHandler(new DataHandler(fds));
                   mbp.setFileName(fds.getName());
                   mp.addBodyPart(mbp);
                   PosIndex += 3;
                   StartIndex = PosIndex;
                // Last, or only, attachment file
                if (StartIndex < Attachments.length()) {
                   MimeBodyPart mbp = new MimeBodyPart();
                   FileDataSource fds = new FileDataSource(Attachments.substring(StartIndex));
                   mbp.setDataHandler(new DataHandler(fds));
                   mbp.setFileName(fds.getName());
                   mp.addBodyPart(mbp);
             // Add the Multipart to the message
             msg.setContent(mp);
             // set the Date: header
             msg.setSentDate(new Date());
             // Send the message
             Transport.send(msg);
          } catch (MessagingException MsgException) {
             ErrorMessage[0] = MsgException.toString();
             Exception TheException = null;
             if ((TheException = MsgException.getNextException()) != null)
               ErrorMessage[0] = ErrorMessage[0] + "\n" + TheException.toString();
               ErrorStatus = 1;
          return ErrorStatus;
       } // End Send Class
    } // End of public class SendMail

    i changed my smtp server and now i am getting the following error...please help
    C:\trainee>java Emailer
    Cannot send email. javax.mail.SendFailedException: Invalid Addresses;
    nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 504 <nb123@tcs05>: Sende
    r address rejected: need fully-qualified address
    nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 504 <nb123@tcs05>: Sende
    r address rejected: need fully-qualified address
    nested exception is:
    com.sun.mail.smtp.SMTPAddressFailedException: 504 <nb123@tcs05>: Sende
    r address rejected: need fully-qualified address

  • Update USR table from Java Code outside OIM

    Hi,
    I want to update a particular field in the USR table using the update query specifically from the java code. I dont want use updateUser api.
    I have written the code which works fine for some userids. But for some user ids it gets the tcUtility object successfully but when trying to execute the update query, it throws the tcDatasetException with message as Data Access Error.
    Please let me know how can i achieve this.
    Also let me know the groups the userid should be member to execute a update query on OIM DB from external java code..
    TIA...

    You are performing an unsupported process. I suggest you correctly code a connection to OIM, and perform the update correctly.
    If you need to update the database directly, use jdbc java connection and run the update. You can do a google search for jdbc and java to find plenty of samples.
    -Kevin

  • Want to send email notification to xelsysadm/OIM superadmin

    Hi,
    I have a requirement, that if the return value of the Flag is true, then send out email notification to OIMsuperadmin which is nothing but xelsysadm. I have written the code till the return flag value, now I want to send out email notification to xelsysadm.
    Please help me with the code.
    Thanks.

    Hi,
    OIM provide a send email utility, you can those API to send email to xelsysadm...
    Regards
    Alabhay Goel

  • Send email by code using button in a repeating table

    Hi
    I have got a repeating table with textboxA, 1 people group textbox and a button. What I want is, when the button is clicked, an email should go out to the person's account selected in the people/group textbox with the contents of the textboxA value.
    How do I do that in infopath, I  tried the below code just to see if the email was going out, but I was getting a permission error. 
    MailMessage MailMsg = new MailMessage();
    MailMsg.Body = "This is a test message and currently logged in user is " + System.Environment.UserName;
    MessageBox.Show("This is a test message and currently logged in user is " + System.Environment.UserName);
    //CTRL65_5_Clicked.Enabled = false;
    MailMsg.From = new MailAddress("[email protected]");
    MailMsg.To.Add("[email protected]");
    MailMsg.Subject = "InfoPath Test Message";
    SmtpClient server = new SmtpClient("test.smtp.com");
    server.Send(MailMsg);

    Hello,
    First make your form as full trust from form options and verify if you get any permission issue or not.
    Go to "File", then "Form Option", click on "Security Level" und clear the checkbox next to "Automatically determine security level" and instead select "Full Trust".
    Later you need to follow below link to send email to selected user of person picker field.
    http://blogs.msdn.com/b/infopath/archive/2006/04/05/569338.aspx?PageIndex=4
    Let us know your result
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Outlook 2013 crashing when sending email Exception code 0xc0000602 MSO.dll error

    Two are three times a week Outlook crashes when sending email with the following error
    Log Name:      Application
    Source:        Application Error
    Date:          15/01/2015 10:00:58
    Event ID:      1000
    Task Category: (100)
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      ********.***.local
    Description:
    Faulting application name: OUTLOOK.EXE, version: 15.0.4667.1000, time stamp: 0x543d3698
    Faulting module name: mso.dll, version: 15.0.4675.1002, time stamp: 0x5474349b
    Exception code: 0xc0000602
    Fault offset: 0x011b1687
    Faulting process id: 0x11dc
    Faulting application start time: 0x01d030a6e4aa1ee7
    Faulting application path: C:\Program Files (x86)\Microsoft Office\Office15\OUTLOOK.EXE
    Faulting module path: C:\Program Files (x86)\Common Files\Microsoft Shared\Office15\mso.dll
    Report Id: 66ad29a2-9c9d-11e4-b53c-082e5f1727fc
    Event Xml:
    <Event xmlns
      <System>
        <Provider Name="Application Error" />
        <EventID Qualifiers="0">1000</EventID>
        <Level>2</Level>
        <Task>100</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2015-01-15T10:00:58.000000000Z" />
        <EventRecordID>10015</EventRecordID>
        <Channel>Application</Channel>
        <Computer>Events-HP8200.ICI.local</Computer>
        <Security />
      </System>
      <EventData>
        <Data>OUTLOOK.EXE</Data>
        <Data>15.0.4667.1000</Data>
        <Data>543d3698</Data>
        <Data>mso.dll</Data>
        <Data>15.0.4675.1002</Data>
        <Data>5474349b</Data>
        <Data>c0000602</Data>
        <Data>011b1687</Data>
        <Data>11dc</Data>
        <Data>01d030a6e4aa1ee7</Data>
        <Data>C:\Program Files (x86)\Microsoft Office\Office15\OUTLOOK.EXE</Data>
        <Data>C:\Program Files (x86)\Common Files\Microsoft Shared\Office15\mso.dll</Data>
        <Data>66ad29a2-9c9d-11e4-b53c-082e5f1727fc</Data>
      </EventData>
    </Event>
    Any clues on a fix?

    Hi,
    Thanks for your question.
    This issue might occurs due to lots of reasons. Do you have a virus scanner installed which integrates itself with Outlook? If yes, please try to disable it, and then try again. You might opt to uninstall the virus scanner temporarily to make
    sure it will not interfere the testing.
    Also, lots of Office crash issues are caused by third-party add-ins. You might want to have a check and see if you have any integrated with your Outlook client which might cause the issue.
    Since the issue occurs randomly ("Two are three times a week"), Office
    Safe Mode will not be effective here, just manually disable all third-party add-ins in Outlook FILE>Options>Ass-Ins, use outlook for a period of time, then verify result.
    Regards,
    Ethan Hua
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Error -- Java code using OIM API to find no of users in OIM

    Hi Experts,
    I hav a requirement that I need to query OIM to find out the total no of active users in the system using a stand alone java program to determine some other process. So I have developed a simple java code but it fails in the below line
    rset=userIntf.findAllUsers(map);  -- It throws null pointer exception
    I have tried with deleteUser() instead of findUsers() , still it throws the null pointer exception on the same line.I have checked the other posts in the forum but could not find out where is the mistake. Can u please suggest me??
    Here is the code
    System.setProperty("XL.HomeDir","D:/bea-oim/xellerate");
    System.setProperty("java.security.auth.login.config","D:/bea-oim/xellerate/config/authwl.conf");
    System.setProperty("java.security.policy","D:/bea-oim/xellerate/config/xl.policy");
    System.setProperty("log4j.configuration","D:/bea-oim/xellerate/config/log.properties");
    tcUtilityFactory utilityFactory = null;
    tcUserOperationsIntf userIntf = null;
              try
                   tcResultSet rset;
                   ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
                   final Hashtable env = config.getAllSettings();
                   tcSignatureMessage moSignature = tcCryptoUtil.sign("xelsysadm","PrivateKey");
                   utilityFactory = new tcUtilityFactory(env, moSignature);
                   userIntf=(tcUserOperationsIntf)utilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
                   HashMap map = new HashMap();
                   map.put("Users.Status","Active");
                   rset=userIntf.findAllUsers(map);
    System.out.println(rset.getRowCount());
         catch(NullPointerException ne)
         System.out.println(ne.getMessage());
         ne.printStackTrace();
         catch(Exception e)
         System.err.println(e.getMessage());
         e.printStackTrace();
    Thanks & Regards
    INIYA

    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    import java.util.HashMap;
    import java.util.Properties;
    import java.util.*;
    import Thor.API.tcUtilityFactory;
    import Thor.API.Operations.*;
    import Thor.API.tcResultSet;
    import com.thortech.xl.crypto.tcCryptoUtil;
    import com.thortech.xl.util.config.ConfigurationClient;
    * @author Rajiv
    public class CreateBulkUsers {
    public static void main(String args[])
    System.setProperty("XL.HomeDir", "E:\\oim\\server\\xellerate");
    System.setProperty("java.security.auth.login.config", "E:\\oim\\server\\xellerate\\config\\auth.conf");
    System.setProperty("java.security.policy", "E:\\oim\\server\\xellerate\\config\\xl.policy");
              tcUtilityFactory utilityFactory = null;
    tcUserOperationsIntf userIntf = null;
    try
    com.thortech.xl.util.config.ConfigurationClient.ComplexSetting config = ConfigurationClient.getComplexSettingByPath("Discovery.CoreServer");
    java.util.Hashtable env = config.getAllSettings();
    com.thortech.xl.crypto.tcSignatureMessage moSignature = tcCryptoUtil.sign("xelsysadm", "PrivateKey");
    utilityFactory = new tcUtilityFactory(env, moSignature);
    // System.out.println((new StringBuilder()).append("utilityFactory = ").append(utilityFactory).toString());
    userIntf = (tcUserOperationsIntf)utilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
    HashMap map = new HashMap();
    map.put("Users.Status", "Active");
    tcResultSet rset = userIntf.findAllUsers(map);
    System.out.println(rset.getRowCount());
    catch(NullPointerException ne)
    System.out.println(ne.getMessage());
    ne.printStackTrace();
    catch(Exception e)
    System.err.println(e.getMessage());
    e.printStackTrace();
    Include all the JARs to run this class from outside not only of OIm of JBoss or Weblogic also.
    eg: jboss\client and jboss\lib

  • MailServiceHelper Failed while sending email java.lang.NullPointerException

    Hi guys,
    I am trying to send email with Adobe CQ API.
    But i am getting a nullpointer exception at this line:  MsgGateway.send(htmlEmail);    
    This is my method that i am using to send.
    import com.day.cq.mailer.MessageGateway;
    import com.day.cq.mailer.MessageGatewayService;
    import javax.mail.internet.InternetAddress;
       public boolean sendHtmlEmail(SlingHttpServletRequest sling,
                String fromMailAdress, List<String> recepientmailAddress,
                String emailSubject, String htmlbodyMail) {
            HtmlEmail htmlEmail = new HtmlEmail();
            List<InternetAddress> emailAddress = new ArrayList<InternetAddress>();
            try {
                for (String recipient : recepientmailAddress) {
                    if (!StringUtil.isEmpty(recipient)) {
                        emailAddress.add(new InternetAddress(recipient));
                        log.error(recipient);
                if (!StringUtil.isEmpty(fromMailAdress)) {
                    htmlEmail.setFrom(fromMailAdress);
                htmlEmail.setTo(emailAddress);
                htmlEmail.setSubject(emailSubject);
                htmlEmail.setHtmlMsg(htmlbodyMail);
                htmlEmail.setCharset("utf-8");
                MessageGatewayService MsgService = getMessageGateWayService(sling);
                MessageGateway<HtmlEmail> MsgGateway = MsgService.getGateway(HtmlEmail.class);
                MsgGateway.send(htmlEmail);   //nullpointer exception caught here        
                return true;
            } catch (Exception e) {
                log.error("Failed while sending email", e);
            return false;
    I have checked to ensure the bundle com.day.cq.cq-mail and my own bundle is running .
    I am also sure that 'htmlEmail' is not null by retrieving the email subject via .getSubject and it did return me the subject.
    I do not understand what is returning the nullpointerexception.
    Thanks in advance !

    The MessageGateway instance (MessageGateway<HtmlEmail> MsgGateway) is null therby throwing a null pointer.
    Instead of instanciating msgGateway as :
    MessageGatewayService MsgService = getMessageGateWayService(sling);
    MessageGateway<HtmlEmail> MsgGateway = MsgService.getGateway(HtmlEmail.class);
    Inject your MessageGateway as:
    @Reference
    private MessageGateway<HtmlEmail> msgGateway;
    and then call send on msgGateway as msgGateway.send(htmlEmail)
    ~ Aditya

  • Problem: Error while sending Email.(Java Mail API)

    Hi to ALL
    I am trying to build Application to send Email
    Below code is primary code to send Email to other smtp host.
    & also debug information is as shown below.
    If possible, then please send the solution.
    -------------------------------Code :-----------------------------------------
    URLName urlN=new URLName("smtps://"+userNm+":"+passwd+"@"+host);
    Properties props = System.getProperties();
    Session session = Session.getDefaultInstance(props);
    session.setDebug(true);
    Message msg = new MimeMessage(session);
    msg.setFrom(new InternetAddress(from));
    InternetAddress[] address= InternetAddress.parse(to, false);
    msg.setRecipients(MimeMessage.RecipientType.TO, address);
    msg.setSubject("subject");
    msg.setContent("messageSend Hi", "text/plain");
    Transport transport=session.getTransport(urlN);
    transport.connect();
    transport.sendMessage(msg, address);
    ---------- Java Run ----------
    DEBUG: setDebug: JavaMail version 1.3.2
    DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun Microsystems, Inc]
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "hostName", port 465, isSSL true
    220 smtp110.mail.mud.yahoo.com ESMTP
    DEBUG SMTP: connected to host "hostName", port: 465
    EHLO patil
    250-smtp110.mail.mud.yahoo.com
    250-AUTH LOGIN PLAIN XYMCOOKIE
    250-PIPELINING
    250 8BITMIME
    DEBUG SMTP: Found extension "AUTH", arg "LOGIN PLAIN XYMCOOKIE"
    DEBUG SMTP: Found extension "PIPELINING", arg ""
    DEBUG SMTP: Found extension "8BITMIME", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<from email address>
    530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
    com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for help go to http://help.yahoo.com/help/us/mail/pop/pop-11.html
    at com.sun.mail.smtp.SMTPTransport.issueSendCommand(SMTPTransport.java:1275)
    at com.sun.mail.smtp.SMTPTransport.mailFrom(SMTPTransport.java:895)
    at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:524)
    at SendEmail2.<init>(SendEmail2.java:46)
    at SendEmail2.main(SendEmail2.java:23)
    Exception : com.sun.mail.smtp.SMTPSendFailedException: 530 authentication required - for help go to
    http://help.yahoo.com/help/us/mail/pop/pop-11.htmls
    -------------------------------------------------------------------------------------

    It's possible. It's only software, after all.
    But it's not easy. It effectively involves
    screen scraping the HTML pages.
    There used to be a third party JavaMail provider
    that did all the hard work, but it has disappeared.

  • Error while sending email using TemplateEmailSender in CSC server

    Hi,
    We are trying to send email using TemplateEmailSender from CSC server. But it is giving Null Pointer Exception in ProfiledMessageSource like below. The same code is working fine in commerce instance but it is failing in CSC instance. We are using ATG2007.1p3
    Any pointers would be helpful.
    Below is the error.
    Error while sending email
    java.lang.NullPointerException
            at atg.userprofiling.dms.ProfiledMessageSource.isConfiguredForProfileSubject(ProfiledMessageSource.java:196)
            at atg.userprofiling.dms.DPSMessageSource.fireEndSessionMessage(DPSMessageSource.java:864)
            at atg.userprofiling.dms.DPSMessageSource.fireEndSessionMessage(DPSMessageSource.java:848)
            at atg.userprofiling.SessionEventTrigger.nameContextElementPreUnbound(SessionEventTrigger.java:553)
            at atg.nucleus.GenericContext.sendPreUnboundEvent(GenericContext.java:200)
            at atg.nucleus.GenericContext.preNotifyRemovedObject(GenericContext.java:528)
            at atg.nucleus.GenericContext.removeElement(GenericContext.java:566)
            at atg.servlet.SessionNameContext.unbindFromNameContext(SessionNameContext.java:557)
            at atg.servlet.SessionNameContext.stopSession(SessionNameContext.java:534)
            at atg.servlet.SessionNameContext.decrementWrapperCount(SessionNameContext.java:242)
            at atg.servlet.SessionBindingReporter.valueUnbound(SessionBindingReporter.java:206)
            at org.apache.catalina.session.StandardSession.removeAttributeInternal(StandardSession.java:1625)
            at org.apache.catalina.session.StandardSession.expire(StandardSession.java:749)
            at org.apache.catalina.session.StandardSession.expire(StandardSession.java:655)
            at org.apache.catalina.session.StandardSession.invalidate(StandardSession.java:1100)
            at org.apache.catalina.session.StandardSessionFacade.invalidate(StandardSessionFacade.java:150)
            at atg.userprofiling.email.TemplateInvoker$TemplateSession.endSession(TemplateInvoker.java:935)
            at atg.userprofiling.email.TemplateEmailSender.createMessage(TemplateEmailSender.java:2387)

    Thanks for the reply.
    My issue is fixed now. It is JBOSS configuration issue. Sessions are not maintained properly that's why we are getting NULL profile in the session. Our application has multiple WARs so we fixed it by setting emptySessionPath to TRUE. If emptySessionPath attribute in server.xml is false, then each WAR will have its own jsessionid cookie.
    I did not touch ProfiledMessageSource as its required for session triggering.

  • Hooking up Response Codes to Java code

    Hello everyone. I have created java code for OIM 11.1.1.3.0, which essentially returns a boolean.
    This code returns true if executed without issue, it returns false if there's some issue that prevents completion.
    My question is this: How do I map the boolean return to reflect the Response code in OIM. If the code returns 'true' I want the resource to have a 'Provisioned' status, and if it returns 'false' I want the resource to have a 'Provisioning' status.
    Where do I need to go to hook up the code's return to the OIM response mapping?
    Thanks in advance!

    Ok, so I've changed my code from a boolean to a String, as you had stated earlier.
    Now it returns "Success" on success of the try-block code and "Failure" in the catch.
    I have used the Resource Workflow (Nexaweb) editor from Manage Resources in the Advanced Console and have created and linked two response codes to the user creation task. The following are the values for the two responses:
    Response Code: Success
    Response Status: C
    Response Description: The task succeeded
    Response Code: Failure
    Response Status: R
    Response Description: The task failed.
    In the 'Create User' task, under the 'Resource Status Management' tab, I have mapped Provisioned to C and Provisioning to R, but every time I attempt to provision the resource, it provisions with a 'Provisioned' status, even though the 'Failure' string was returned from the catch block (as shown in the logs)
    The only thing I can think of now is that my adapter isn't configured correctly, as I left the output variable undefined... Is that necessary to hook up in order for responses to work? It would seem logical.

  • Send email notification when the baseline and actual values are different in project

    Hi
    I am working with MS Project 2013 and Project Server 2013.
    I need to the send email notification to the program manager (or to a user) whenever the project manager changes the task finish date for a task. Comparison should happen with the baseline finish and the difference needs to be updated to the Program Manager
    over mail.
    How to configure/customize email notification for changes in MPP.
    Please suggest.
    Regards,
    Sudhir

    If you are not having developer skills it will be complicated for you.
    You need to create event handler by code, as in the below link:
    http://msdn.microsoft.com/en-us/library/office/gg615466%28v=office.14%29.aspx
    Then compare your values and finally send email by code.
    Twitter : @MShoubaki | http://jo.linkedin.com/in/mshoubaki

  • OIM should send spmlv2 requests via java code to service provider

    Hi,
    We have the situation in which OIM acts as Requesting authority,Spml provider acts as service provider.
    Oim should send spml requests from custom java code.Spml2Client is used.We are not using genericc technology connector.
    Require sample java code for Search operation.
    I had done for modify request.
    The request and response is as follows
    PSO ID returned after searching: org.openspml.v2.msg.spml.PSOIdentifier@5c32a864
    <deleteRequest xmlns='urn:oasis:names:tc:SPML:2:0' recursive='false'/>
    <deleteResponse xmlns='urn:oasis:names:tc:SPML:2:0' status='success'/>
    <modifyRequest xmlns='urn:oasis:names:tc:SPML:2:0' returnData='identifier'>
    <psoID ID='cn=TPS User8,ou=TPS,dc=fosterstechodc,dc=com'/>
    <modification modificationMode='replace'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='otherHomePhone' operation='replace'>
    <dsml:value>999999</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='delete'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='description' operation='delete'>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='add'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='firstname' operation='add'>
    <dsml:value>Barbara</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    </modifyRequest>
    SpmlClient: sending to http://10.101.151.209/ARServerSPML/SPMLProvider.asmx
    <modifyRequest xmlns='urn:oasis:names:tc:SPML:2:0' returnData='identifier'>
    <psoID ID='cn=TPS User8,ou=TPS,dc=fosterstechodc,dc=com'/>
    <modification modificationMode='replace'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='otherHomePhone' operation='replace'>
    <dsml:value>999999</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='delete'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='description' operation='delete'>
    </dsml:modification>
    </data>
    </modification>
    <modification modificationMode='add'>
    <data>
    <dsml:modification xmlns:dsml='urn:oasis:names:tc:DSML:2:0:core' name='firstname' operation='add'>
    <dsml:value>Barbara</dsml:value>
    </dsml:modification>
    </data>
    </modification>
    </modifyRequest>
    SpmlClient: received
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><modifyResponse status="failure" xmlns="urn:oasis:names:tc:SPML:2:0"><error>malformedRequest</error><errorMessage>At least one &lt;modification&gt; element must be specified.</errorMessage></modifyResponse></soap:Body></soap:Envelope>
    <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><modifyResponse status="failure" xmlns="urn:oasis:names:tc:SPML:2:0"><error>malformedRequest</error><errorMessage>At least one &lt;modification&gt; element must be specified.</errorMessage></modifyResponse></soap:Body></soap:Envelope>
    org.openspml.v2.util.Spml2ExceptionWithResponse: At least one <modification
    The response says the modifaction tag is not present.
    The code for this request is
    Modification[] modifications =
                   { newModWithDSMLMod("otherHomePhone", "999999", ModificationMode.REPLACE),
                             newModWithDSMLMod("description", null, ModificationMode.DELETE),
                             newModWithDSMLMod("cn", "Barbara", ModificationMode.REPLACE)};
                   modifyResp = customSPMLClient.modifyUser(client,searchPSOId,modifications);
    method:
    public ModifyResponse modifyUser(Spml2Client client,PSOIdentifier psoId,Modification[] modifications) throws Exception {
              client.setTrace(true);
              ReflectiveXMLMarshaller marshaller = new ReflectiveXMLMarshaller();
              ModifyRequest modReq = new ModifyRequest(null, // String requestId,
                        null, // ExecutionMode executionMode,
                        psoId, // PSOIdentifier psoID
                        modifications, // Modification[] modifications
                        ReturnData.IDENTIFIER // ReturnData returnData
              System.out.println(modReq.toXML(marshaller));
              ModifyResponse modResp = (ModifyResponse) client.send(modReq);
              System.out.println(modResp.toXML(marshaller));
              return modResp;
    private static Modification newModWithDSMLMod(String modName, String modValue, ModificationMode modMode)
         throws DSMLProfileException
              /*DSMLModification dsmlMod = null;
              dsmlMod = new DSMLModification(modName, modValue, modMode);
              Extensible data = new Extensible();
              data.addOpenContentElement(dsmlMod);
              Selection component = null;
              return new Modification(component, data, null, modMode);
    Please help me out.
    I need sample java code for search operation tooo.
    regards,
    Sindhu.M

    the sample JAVA codes are provided for sending SPML requests, HTTPClient and one more (i dont remember rite now) within the OIM installation folders itself. It's in the 'SampleHttpClient' folder. Check it once. WSDL, sample XML's and the JAVA codes all are there. You just need to set the classpath and run it.
    - oidm.

Maybe you are looking for