Java code to send email only works for one email id? -


The code given below in Java is used to send emails to people in my team but it only works When string is fixed on public = "Marsh@gmail.com"; But if I have the public static string = "marsh@gmail.com, mark@gmail.com", then this will not work; Do not I remember that someone can help me send emails to many IDs at the same time? Currently the code can only be sent to one person at the same time?

  public static string = "marsh@gmail.com, mark@gmail.com"; = "Static" string from "SANDBOX"; Public stable string host = "localhost"; Public static zero send_production_email (string report date) {System.out.println ("Preparing to send email to admin ..."); Properties Properties = System.getProperties (); Properties.setProperty ("mail.smtp.host", host); Session session = session .get default difference (properties); {Try MimeMessage Message = New MimeMessage (Session); Message.setFrom (new Internet address (from)); Message.addRecipient (Message.RecipientType.TO, new Internet address); Message.setSubject ("Successfully backed up production database"); "+ +" Report Data + Back Up "+ Report Date +" & lt; / H4 & gt; & Lt; Br> "+" & Lt; h4 & gt; Please do not reply to this email because it is an automatically generated email & lt; / H4> & Lt; / Br & gt; "+" & Lt; h4 & gt; Thanks! & Lt; / H4 & gt; & Lt; / Br & gt; "); Transport.send (Message); System.out.println (" Message sent successfully ... ");} Catch (messaging expansion max) {mex.printStackTrace ();}}    

You need to call message.addRecipient () for each email address Or addRecipients () with an array of addresses.

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -