Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7831177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:36:42+00:00 2026-06-02T11:36:42+00:00

I want to attach multiple images with email in BB. How can I do

  • 0

I want to attach multiple images with email in BB. How can I do this? Does any body have an idea? please help me.Below is my code which works fine when i send only one image with email. so what modification should I make in my code for attaching multiple images.

  public static void SendMailAttachment(Bitmap screenshot)
            {            

              String htmlContent = "String" ;     
                  try 
                  {
                       Multipart mp = new Multipart();
                       Message msg = new Message();
                       Address[] addresses = {new Address("","")};

                   for (int i = 0; i<2 ; i++)
                     {
                            PNGEncodedImage img = PNGEncodedImage.encode(screenshot);
                            SupportedAttachmentPart pt = new SupportedAttachmentPart(mp, img.getMIMEType(),
                            "Weed.png", img.getData());
                            mp.addBodyPart(pt);

                      }
                            msg.setContent(mp);
                            msg.setContent(htmlContent);

                       msg.addRecipients(RecipientType.TO, addresses);
                       msg.setSubject("Subject");          
                       Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES, new MessageArguments(msg));

                  }
                  catch (AddressException ex) 
                  {
                      System.out.println("Exception -->"+ex.getMessage()); 
                  } 
                  catch (MessagingException ex) 
                  {
                      System.out.println("Exception -->"+ex.getMessage()); 
                  }

        }

Thanx in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T11:36:43+00:00Added an answer on June 2, 2026 at 11:36 am

    following code can be used to attach multiple images or files.

    public void upload()
        {     
            Multipart mp = new Multipart();
        String fileName = null;
    
    
    
        for (int i = 0; i<2 ; i++)
        {
    
    
            //          Dialog.alert(image.);
            byte[] stream = readStream("file:///SDCard/IMG00001-20110404-1119.JPEG");
            SupportedAttachmentPart sap = new SupportedAttachmentPart(mp, MIMETypeAssociations.getMIMEType("IMG00001-20110404-1119.JPEG"),"IMG00001-20110404-1119.JPEG", stream);
            mp.addBodyPart(sap);
    
        }
    
    
        TextBodyPart tbp = new TextBodyPart(mp,"test bodyString");
        mp.addBodyPart(tbp);
    
        Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);
        Message message = new Message(folders[0]);
        Address[] toAdds = new Address[1];
    
        try {
            toAdds[0] = new Address("testmailid", null);
            message.addRecipients(Message.RecipientType.TO,toAdds);
            //          message.setFrom(new InternetAddress(_from)); 
    
            //          message.addRecipients(Message.RecipientType.FROM,toAdds);
            message.setContent(mp);
            message.setSubject("test subject");
            Transport.send(message);
    
            Dialog.alert("message send successfully.");
    
        } catch (AddressException e) {
            // TODO Auto-generated catch block
            //          e.printStackTrace();
            Dialog.alert(e.getMessage());
    
        } catch (MessagingException e) {
            // TODO Auto-generated catch block
            //          e.printStackTrace();
            Dialog.alert(e.getMessage());
        }
    }
    
    private byte[] readStream(String path) 
    {
    
    
    InputStream in = null;
        FileConnection fc = null;
    byte[] bytes = null;
    
    try
    {
        fc = (FileConnection) Connector.open(path);
        if (fc !=null && fc.exists()) 
        {
            in = fc.openInputStream();
            if (in !=null)
            {
                bytes = IOUtilities.streamToBytes(in);
            }
        }
    }
    catch(IOException e) 
    {
    
    }
    finally
    {
        try
        {
            if (in != null) 
            {
                in.close();
            }
        }
        catch(IOException e)
        {                
        }
        try
        {
            if (fc !=null)
            {
                fc.close();
            }
        }
        catch(IOException e)
        {                
        }
    
    }       
    return bytes;         
    

    }

    i have used this code. it works fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application I want to attach multiple photos to an email in code,
i have a Button on a HTML page . i want to attach file
want to have a Hyperlink-Button in a gridView in which I can display a
I have a crud with paperclip and multiple images' i implement active_admin and the
I want to have multiple checkbox values be stored into one field in a
All, I have an application that needs to attach and detach multiple SQL databases
I have 2 entity types Buyers and BuyerOrders. Buyer can contain multiple BuyerOrders and
Okay I've tried multiple things and looked for answers to this and I can't
I have seen examples containing things like this: mountSharedResource(/images/logo.gif, new ResourceReference(ImageScope.class, logo.gif).getSharedResourceKey()); mountSharedResource(/resource, Application.class.getName()
I want to send a HTML file as message body and want to attach

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.