Results 1 to 4 of 4
  1. #1
    Naren222 is offline Member
    Join Date
    Jun 2013
    Posts
    4
    Rep Power
    0

    Default Javamail for sending group mail to lists

    Hello everyone,

    I am using javax.mail.* package and its API's to send e-mail, as in the below link.
    [Moderator edit: link removed]

    But, Am able to do send e-mails only if the mail id is an individual mail ID. If the mail ID is a list like
    "abc-group-list@list.company-name.com" its telling invalid address. Is this not supported or am i doing something wrong ?

    Thanks and Regards,
    Naren
    Last edited by DarrylBurke; 06-25-2013 at 01:52 PM. Reason: Removed spammy link

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Javamail for sending group mail to lists

    If you want advice on your code, post that code here after first going through the Guide For New Members and BB Code List - Java Programming Forum - Learn Java Programming

    I've removed the link to an external site.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Naren222 is offline Member
    Join Date
    Jun 2013
    Posts
    4
    Rep Power
    0

    Default Re: Javamail for sending group mail to lists

    Hello everyone,

    I am using javax.mail.* package and its API's to send e-mail, as below

    But, Am able to do send e-mails only if the mail id is an individual mail ID. If the mail ID is a list like
    "abc-group-list@list.company-name.com" its telling invalid address. Is this not supported or am i doing something wrong ?

    Thanks and Regards,
    Naren


    Java Code:
    import java.util.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    import javax.mail.internet.InternetAddress;
    import javax.mail.internet.MimeBodyPart;
    import javax.mail.internet.MimeMessage;
    import javax.mail.internet.MimeMessage.RecipientType;
    import javax.mail.internet.MimeMultipart;
    
    
    public class SendEmail
    {
       public static void main(String [] args)
       {    
    
          String to = "abc@company.com";
          String from = "AutomaticMailer@company.com";
          String host = "mail.company-name.com";
          String attachFile = "C:/Report.txt";
          String attachFileName = "Report.txt";
          
          String attachFile1 = "C:/SupportFile.txt";
          String attachFileName1 = "SupportFile.txt";
          
          String attachFile2 = "C:/Commands.txt";
          String attachFileName2 = "CheckModulesCommands.txt";
          
          Properties properties = System.getProperties();
          properties.setProperty("mail.smtp.host", host);
    
          Session session = Session.getDefaultInstance(properties);
    
          try
          {
             MimeMessage message = new MimeMessage(session);
             message.setFrom(new InternetAddress(from));
    
             message.addRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
             message.setSubject("This is the Subject Line!");
             message.setText("This is actual message");
             MimeBodyPart messageBodyPart = new MimeBodyPart();  
    
             messageBodyPart.setText("Test mail one");  
             Multipart multipart = new MimeMultipart("mixed");  
             multipart.addBodyPart(messageBodyPart);  
             
             // File 1 attachment
             messageBodyPart = new MimeBodyPart();  
             DataSource source = new FileDataSource(attachFile);  
             messageBodyPart.setDataHandler(new DataHandler(source));  
             messageBodyPart.setFileName(attachFileName);
             multipart.addBodyPart(messageBodyPart);
             
             // File 2 attachment
             messageBodyPart = new MimeBodyPart();  
             DataSource source1 = new FileDataSource(attachFile1);  
             messageBodyPart.setDataHandler(new DataHandler(source1));  
             messageBodyPart.setFileName(attachFileName1);
             multipart.addBodyPart(messageBodyPart);
             
             
             // Third attachment
             messageBodyPart = new MimeBodyPart();  
             DataSource source2 = new FileDataSource(attachFile2);  
             messageBodyPart.setDataHandler(new DataHandler(source2));  
             messageBodyPart.setFileName(attachFileName2);
             multipart.addBodyPart(messageBodyPart);
             
             message.setContent(multipart);  
             
             // Send message
             Transport.send(message);
             
             System.out.println("Sent message successfully !!!!!!");
                      
          }
          catch (MessagingException mex)
          {
             mex.printStackTrace();
          }
       }
    }

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,193
    Rep Power
    19

    Default Re: Javamail for sending group mail to lists

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 5
    Last Post: 10-12-2011, 07:03 AM
  2. problem with sending mail usin javaX.mail api
    By sandeepsai39 in forum New To Java
    Replies: 4
    Last Post: 11-25-2009, 05:37 AM
  3. Replies: 2
    Last Post: 07-25-2009, 09:36 AM
  4. Sending a mail with the local mail program
    By thedude in forum Advanced Java
    Replies: 2
    Last Post: 07-23-2007, 12:19 PM
  5. Sending mail Using JAVAMAIL
    By peiceonly in forum Advanced Java
    Replies: 3
    Last Post: 07-19-2007, 02:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •