关于发送邮件的问题

horse_leo_zhcn 2015-12-02 10:11:46
products_list.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title>Title</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<form action="products" method="post">
<table class="products_table" align="center" border="1" width="90%" cellpadding="0" cellspacing="0">
<tr>
<th>编号</th>
<th>产品名称</th>
<th>规格型号</th>
<th>计量单位</th>
<th>数量</th>
<th>材质</th>
<th>料厚</th>
<th>表面处理</th>
<th>盖板</th>
<th>隔板</th>
<th>备注</th>
</tr>
<tr>
<td name="id">1</td>
<td><input type="text" name="products_name"></td>
<td><input type="text" name="products_model"></td>
<td><input type="text" name="products_units"></td>
<td><input type="text" name="products_number"></td>
<td><select name="material">
<option>--请选择--</option>
<option>碳钢</option>
<option>不锈钢</option>
<option>铝合金</option>
<option>镀锌板</option>
</select></td>
<td><input type="text" name="products_thickness"></td>
<td><select name="surface">
<option>--请选择--</option>
<option>喷粉</option>
<option>热侵锌</option>
<option>阳极氧化</option>
<option>钝化</option>
</select></td>
<td><select name="cover_plate">
<option>--请选择--</option>
<option>有</option>
<option>无</option>
</select></td>
<td><select name="partition">
<option>--请选择--</option>
<option>有</option>
<option>无</option>
</select></td>
<td><input type="text" name="notes"></td>
</tr>
<tr>
<td name="id">2</td>
<td><input type="text" name="products_name"></td>
<td><input type="text" name="products_model"></td>
<td><input type="text" name="products_units"></td>
<td><input type="text" name="products_number"></td>
<td><select name="material">
<option>--请选择--</option>
<option>碳钢</option>
<option>不锈钢</option>
<option>铝合金</option>
<option>镀锌板</option>
</select></td>
<td><input type="text" name="products_thickness"></td>
<td><select name="surface">
<option>--请选择--</option>
<option>喷粉</option>
<option>热侵锌</option>
<option>阳极氧化</option>
<option>钝化</option>
</select></td>
<td><select name="cover_plate">
<option>--请选择--</option>
<option>有</option>
<option>无</option>
</select></td>
<td><select name="partition">
<option>--请选择--</option>
<option>有</option>
<option>无</option>
</select></td>
<td><input type="text" name="notes"></td>
</tr>
</table>
<button type="submit">提交</button>
</form>
</body>
</html>


Products.java
package com.mtqj.onlinesales.controller;

/**
* Created by mtqj-chengke on 2015/12/1.
*/
public class Products {
private String id;
private String products_name;
private String products_model;
private String products_units;
private String products_number;
private String material;
private String products_thickness;
private String surface;
private String cover_plate;
private String partition;
private String notes;

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getProducts_name() {
return products_name;
}

public void setProducts_name(String products_name) {
this.products_name = products_name;
}

public String getProducts_model() {
return products_model;
}

public void setProducts_model(String products_model) {
this.products_model = products_model;
}

public String getProducts_units() {
return products_units;
}

public void setProducts_units(String products_units) {
this.products_units = products_units;
}

public String getProducts_number() {
return products_number;
}

public void setProducts_number(String products_number) {
this.products_number = products_number;
}

public String getMaterial() {
return material;
}

public void setMaterial(String material) {
this.material = material;
}

public String getProducts_thickness() {
return products_thickness;
}

public void setProducts_thickness(String products_thickness) {
this.products_thickness = products_thickness;
}

public String getSurface() {
return surface;
}

public void setSurface(String surface) {
this.surface = surface;
}

public String getCover_plate() {
return cover_plate;
}

public void setCover_plate(String cover_plate) {
this.cover_plate = cover_plate;
}

public String getPartition() {
return partition;
}

public void setPartition(String partition) {
this.partition = partition;
}

public String getNotes() {
return notes;
}

public void setNotes(String notes) {
this.notes = notes;
}

@Override
public String toString() {
return "Products{" +
"id='" + id + '\'' +
", products_name='" + products_name + '\'' +
", products_model='" + products_model + '\'' +
", products_units='" + products_units + '\'' +
", products_number='" + products_number + '\'' +
", material='" + material + '\'' +
", products_thickness='" + products_thickness + '\'' +
", surface='" + surface + '\'' +
", cover_plate='" + cover_plate + '\'' +
", partition='" + partition + '\'' +
", notes='" + notes + '\'' +
'}';
}
}


sendMail.java
package com.mtqj.onlinesales.controller;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

/**
* Created by mtqj-chengke on 2015/11/30.
*/
@Controller
public class sendMail {

@RequestMapping("/products")
public String products(Products products) {

SimpleEmail email = new SimpleEmail();
email.setHostName("smtp.163.com");
email.setAuthentication("ceshi", "123456");

try {
email.setFrom("ceshi@163.com");
email.addTo("cs@163.com", "Leo", "UTF-8");
email.setSubject("测试邮件");
email.setMsg(String.valueOf(products));
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
System.out.println(products);
return "products";
}
}


问题:
products_list.jsp的运行界面如下:


当我填写或者选择之后,点击提交按钮,我怎样才能将这个表格以表格的形式,将已经填好内容的信息发送到我指导的邮箱当中,这个表格的内容至少有2行,或者更多(我会增加新行)。

请各位高手给予指导!!!
...全文
84 2 点赞 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
Mr__feng 2015-12-02
提问的时候建议把你的问题描述倒着排序下,我看问题喜欢先看重点(问题根本和最主要的代码片段),再看次要(辅助性的代码)。
  • 打赏
  • 举报
回复
Mr__feng 2015-12-02
apache common email下有一个叫做HtmlEmail的对象,利用这个对象应该可以发送Html格式的邮件。 至于你邮件内容,你可以在JS中把表格的源码作为参数传递到后台,表格源码即是你的邮件内容。亲,你可以尝试下
  • 打赏
  • 举报
回复
相关推荐
发帖
Web 开发
创建于2007-09-28

8.0w+

社区成员

Java Web 开发
申请成为版主
帖子事件
创建了帖子
2015-12-02 10:11
社区公告
暂无公告