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 7861627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T22:48:15+00:00 2026-06-02T22:48:15+00:00

I want to send email programmatically. For that, i wrote the below code: if(field

  • 0

I want to send email programmatically. For that, i wrote the below code:

if(field == m_btnSend)
    {
        Store store = Session.getDefaultInstance().getStore();
        Folder[] folder = store.list(Folder.SENT);
        Folder sent = folder[0];

        Message msg = new Message(sent);
        Address receipent[] = new Address[1];
        try
        {
            receipent[0] = new Address("arindam.hit@gmail.com", "Arindam");

            msg.addRecipients(Message.RecipientType.TO, receipent);

            msg.setSubject("Test Mail");

            msg.setContent("This mail is to remind you that programmatically we can send the mail");

            msg.setPriority(Priority.HIGH);

            Transport.send(msg);

        }

        catch (Exception e) 
        {
           e.printStackTrace();
        }
    }

I am runnig it in MDS simulator. Now i want to see this mail in by mail inbox if i open my mail through simulator browser. How it is possible??

Thanks.

  • 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-02T22:48:16+00:00Added an answer on June 2, 2026 at 10:48 pm

    This is the code to send the attachments with mail and it works very well on device:

     private  void sendmail()
     {
     try
     {
     Address[] address = new Address[1];
     address[0] = new Address(" "," ");
     Folder folders[] = Session.getDefaultInstance().getStore().list(Folder.SENT);
     msg=new Message(folders[0]);
     msg.addRecipients(Message.RecipientType.TO, address);
     msg.setSubject(" ");
     SupportedAttachmentPart attach = new         SupportedAttachmentPart(multipart,"application/pdf",pdfName,data);
     multipart.addBodyPart(attach);
     msg.setContent(multipart);
     Invoke.invokeApplication(Invoke.APP_TYPE_MESSAGES,new MessageArguments(msg));
    
     try
     {
    Transport.send(msg);
    }
     catch(SendFailedException  e)
     {
      System.out.println("messages for sent : : : :   : : "+e.getMessage());
      }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to send an email to user after he sign-up with code.for ex
After user registration, website send activation code to email. something like that. www.domain.com/?activate=<code> I'm
I want to send email messages that have arbitrary unicode bodies in a Python
I want to send email using the php code, Following is the code should
I have an ASP.NET application hosted on Godaddy that I want to send email
I want to send email to my app users ensuring that every email is
I want to take screen shot through programmatically and send with Email. I am
I want to send email that contains form as a body from my mobile
I have a programmatically generated image that I want to send as an attachment
i want to send email from my application,how can write code for send email

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.