Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to send sms alerts to mobile using java?
    text
    copied!<p>Im developing a simple Email Application, I have done sending email using java with following code.` </p> <pre><code>public class SendMail { public SendMail() throws MessagingException { String host = "smtp.gmail.com"; String Password = "mnmnn"; String from = "xyz@gmail.com"; String toAddress = "abc@gmail.com"; String filename = "C:/Users/hp/Desktop/Write.txt"; // Get system properties Properties props = System.getProperties(); props.put("mail.smtp.host", host); props.put("mail.smtps.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); Session session = Session.getInstance(props, null); MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.setRecipients(Message.RecipientType.TO, toAddress); message.setSubject("JavaMail Attachment"); BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setText("Here's the file"); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); messageBodyPart = new MimeBodyPart(); DataSource source = new FileDataSource(filename); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(filename); multipart.addBodyPart(messageBodyPart); message.setContent(multipart); try { Transport tr = session.getTransport("smtps"); tr.connect(host, from, Password); tr.sendMessage(message, message.getAllRecipients()); System.out.println("Mail Sent Successfully"); tr.close(); } catch (SendFailedException sfe) { System.out.println(sfe); } } }` </code></pre> <p>I want to develope SMSAlert application using java. I want to get sms alerts to my number whenever i get mail. Is it possible in java. Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload