How to use e-mail to control your PC with Java implementation

Source: Internet
Author: User

Two days ago saw an article, using Python to implement e-mail control of the computer's interesting small program

Python video tutorial for controlling the Python version of the computer

But I had no contact with Python and then I thought I could use Java, so I wrote a Java version of

Initially want to connect the mail server with the socket, but more trouble, so found an easy-to-use method, using JavaMail

First, learn to use JavaMail

First we have to implement the use of Java to send and receive mail functions, through the data, we need to learn javamail,javamail development needs to use the following two jar package

: Dot Me

Import the above two jar package into the javaproject can happily use Java to send and receive e-mail, this tutorial a lot of online, there are many videos, I attach two bar:

Java Send mail JavaMail API Core class

Second, realize the idea: ( we use IMAP protocol )

1. Connect to the mail server, we must go through all the mail, find the one we are looking for, is to find new mail from the specified mailbox

2. Locate the specified message, get the subject of the message assigned to the variable, and then set the message to read

3. Call Java to control the functions of the Windows system and then pass in the subject control command.

Problems encountered:

1. How can I get new mail at any time? So we thought of multi-threading, so I used a thread-dead loop to iterate through the mailing list, with the specified new mail immediately accepted (but there are still some problems in the process Control)

2, sometimes connect the mail server will time out, but continue to wait and will connect (temporarily unresolved)

Third, the Code test: (Sina mailbox as an example)

First we need to determine some of the Sina mailbox configuration

Test procedure:

Run may report a connection to the server exception

Because it executes in multiple threads, it will reconnect to the server itself.

Example of success: sending a message with the subject Notepad will open Notepad, such as

Because of beginners javamail and multithreading, this program is not perfect, and continue to improve learning in the future, I think their python version of the very dick, but also to learn, take time to see the Python version of the implementation principle

Program source code Download:

Do me a little harder!

Executable Jar Package:

Hang Me up!

Executable Jar Package Run method:

A Java environment can double-click Open (Compile version jdk1.8.20)

If you look at the printing information of the program, you can put the jar package on the desktop:

can also be run.

How to use e-mail to control your PC with Java implementation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.