使用<h:commandbutton> </h:commandbutton>打开Outlook

时间:2012-12-11 13:44:02

标签: email jsf hyperlink outlook

的相应JSF代码是什么
<a href="mailto:me@domain.com?subject=Sample subject&body=test&cc=cc@domain.com">Send mail</a>

打开Outlook邮箱给用户预先填写邮件模板?

1 个答案:

答案 0 :(得分:4)

假设您使用的是JSF 1.2或更高版本,您可以在JSF页面中使用完全相同的HTML代码。

<a href="mailto:me@domain.com?subject=Sample subject&body=test&cc=cc@domain.com">Send mail</a>

如果您打算根据JSF表单中的值预填充它,那么您需要将重定向发送到该URL。

public void submit() throws IOException {
    // ...

    externalContext.redirect(String.format(
        "mailto:me@domain.com?subject=%s&body=%s&cc=cc@domain.com",
            URLEncoder.encode(subject, "UTF-8"),
            URLEncoder.encode(body, "UTF-8"));
}

请注意,这并不一定在Outlook中准备邮件。它只是在客户端自己的默认邮件客户端中准备邮件,这可能不是Outlook本身。例如,它可能是Thunderbird甚至是Gmail。另请注意,您对没有控制该部分。

相关问题