【发布时间】:2015-02-25 12:47:30
【问题描述】:
我想创建一个按钮,以便用户可以单击,它将打开一个新的小窗口,他们可以在其中发送电子邮件。此窗口将具有“发件人”、“收件人”、“主题”、“内容”字段,所有这些字段都将具有默认文本,用户可以对其进行编辑(“发件人”字段除外)。见下图:
我尝试了什么:
我通过以下方式创建了一个电子邮件表单:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<p>
From:<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</p>
To:<asp:Literal ID="Literal2" runat="server"></asp:Literal>
<p>
Subject:<asp:Literal ID="Literal3" runat="server"></asp:Literal>
</p>
Content:<asp:Literal ID="Literal4" runat="server"></asp:Literal>
</form>
</body>
</html>
然后我尝试将此表单与我当前的代码链接: 当前代码:我可以通过此代码发送电子邮件:
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtpclientaddresshere");
mail.From = new MailAddress("defaultFromEmail@domain.com");
mail.To.Add("email1@yahoo.com,email2@yahoo.com");
mail.Subject = "Test Mail";
mail.Body = "This is for testing SMTP mail";
SmtpServer.Credentials = new System.Net.NetworkCredential("mysmtpserver@something.com", "");
SmtpServer.Send(mail);
现在我不知道是否有权将上述表格用于电子邮件窗口目的?我如何格式化所有字段并将其链接到我的工作代码?
【问题讨论】:
-
好吧,我就是这样做的,只是我将加密的密码存储在 web.config 中。虽然这应该在 Codereview 上,但我正在等待一些好的替代方案
-
如何链接每个表单中的字段?