JSP and JavaMail 3 (try to write the first program)

Source: Internet
Author: User
4. Try to write the first sender program
We have already introduced JavaMail. Next we can try to write our own program.
First, we should first write an HTML program index.htm for writing mail, as shown below:
Bytes -------------------------------------------------------------------------------------------
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Title> email writing </title>
</Head>
<Body>
<Form name = "form1" method = "post" action = "testmail. jsp">
<Table width = "75" border = "0" align = "center" cellspacing = "1" bgcolor = "#006600" class = "black">
<Tr bgcolor = "# FFFFFF">
<Td width = "24%"> recipient address: </td>
& Lt; td width = "76%" & gt;
<Input name = "to" type = "text" id = "to"> </td>
</Tr>
<Tr bgcolor = "# FFFFFF">
<Td> Topic: </td>
<Td>
<Input name = "title" type = "text" id = "title"> </td>
</Tr>
<Tr>
<Td height = "107" colspan = "2" bgcolor = "# FFFFFF">
<Textarea name = "content" cols = "50" rows = "5" id = "content"> </textarea> </td>
</Tr>
<Tr align = "center">
<Td colspan = "2" bgcolor = "# FFFFFF">
<Input type = "submit" name = "Submit" value = "Send">
<Input type = "reset" name = "Submit2" value = "reset">
</Td>
</Tr>
</Table>
</Form>
</Body>
</Html>
Next, we will write another processing program testmail. jsp, as shown below:
Bytes -----------------------------------------------------------------------------------------
<% @ Page contentType = "text/html; charset = GB2312" %>
<% Request. setCharacterEncoding ("gb2312"); %> <! -- Chinese processing code -->
<! -- Introduce the class library to be used -->
<% @ Page import = "java. util. *, javax. mail. *" %>
<% @ Page import = "javax. mail. internet. *" %>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
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.