Last Updated
Viewed 32 Times
  

this is not working and I cannot figure out why

do {
    System.out.println("enter your work email");
    workEmail = scnr.nextLine();
    if (workEmail.substring(workEmail.length() - 4) != ".") {
        System.out.println("Please enter a valid email. example: JohnDoe@yahoo.com");
    }

} while (workEmail.substring(workEmail.length() - 4) != ".");

User will enter email address and click on validate button. and after validation,in next page the email address will be shown as first letter of emailxxxxxxxx(till @ symbol)@domain's first letter namexxxx(till domain name length).com. xxxxx represents the length of name

here i'm able to validate the email address using java regx but not able to display the patterns as mentioned above. any idea to achieve in java. I'm very new to this,for any mistake,excuse me

Here is my code for sending email

Properties props = new Properties();
            props.put("mail.smtp.host", "smtp.abc.com");
            props.put("mail.smtp.socketFactory.port", "465");
            props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
            props.put("mail.smtp.auth", "true");
            props.put("mail.smtp.port", "465");
            Session session = Session.getDefaultInstance(props,
                    new javax.mail.Authenticator() {
                        protected PasswordAuthentication getPasswordAuthentication() {
                            return new PasswordAuthentication("vijaya.teke@abc.com", "********");
                        }

                    });

            try {

                Message message = new MimeMessage(session);
                message.setFrom(new InternetAddress("vijaya.teke@abc.com"));
                message.setRecipients(Message.RecipientType.TO,InternetAddress.parse("vijaya.teke@abc.com"));
                message.setSubject("Testing Subject");
                BodyPart messageBodyPart1 = new MimeBodyPart();
                messageBodyPart1.setText("This is message body");
                MimeBodyPart messageBodyPart2 = new MimeBodyPart();
                String filename = "D:\\Automation\\Automation workspace\\TestSelenium\\Screenshots";
                DataSource source = new FileDataSource(filename);
                messageBodyPart2.setDataHandler(new DataHandler(source));
                messageBodyPart2.setFileName(filename);
                Multipart multipart = new MimeMultipart();
                multipart.addBodyPart(messageBodyPart2);
                multipart.addBodyPart(messageBodyPart1);
                message.setContent(multipart);
                Transport.send(message);
                System.out.println("=====Email Sent=====");

            } catch (MessagingException e) {

                throw new RuntimeException(e);
            }

I am getting error "java.lang.NoClassDefFoundError: com/sun/mail/util/MailLogger" at the line "Session session = Session.getDefaultInstance(props," line. I am not getting the solution. Please help me.

I have made a user table that looks as which includes a custom Name field .

Now whenever I try to put data into this field i get an error .

The code i Used was .

ParseUser user = new ParseUser();
                user.setUsername(Name);
                user.setPassword(Password);
                user.setEmail("nevin.george.sunny@gmail.com");


                user.put("Name","test");

                user.signUpInBackground(new SignUpCallback() {
                    @Override
                    public void done(ParseException e) {
                        if (e == null) {
                            // Show a simple Toast message upon successful registration
                            Toast.makeText(getApplicationContext(),
                                    "Successfully Signed up, please log in.",
                                    Toast.LENGTH_LONG).show();
                        } else {
                            Toast.makeText(getApplicationContext(),
                                    "Sign up Error", Toast.LENGTH_LONG)
                                    .show();
                        }
                    }


                });

But I get the "Sign Up error" Message Displayed .And no updates in the table .

cc