如何在我的 ASP.NET 简历上传表单中添加其他字段
How to add other fields in my ASP.NET CV upload form
我已经成功发送了一封附有 CV/Resume 附件的电子邮件,但是如何在要在电子邮件中显示的表单中添加其他字段(全名和评论)。
我的 aspx.vb 中有以下代码:
Imports System.Net.Mail
Imports System.IO
Partial Class Default_VB
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If FileUpload1.HasFile Then
Dim toAddress As String = "email@address.com"
Dim fromAddress As String = "email@anotheraddress.com"
Dim mailServer As String = "smtp.1and1.com"
Dim myMailMessage As MailMessage = New MailMessage()
myMailMessage.To.Add(toAddress)
myMailMessage.From = New MailAddress(fromAddress)
myMailMessage.Subject = "Test Message"
Dim fileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
Dim myAttachment As New Attachment(FileUpload1.FileContent, fileName)
myMailMessage.Attachments.Add(myAttachment)
Dim mySmtpClient As New SmtpClient(mailServer)
mySmtpClient.Send(myMailMessage)
End If
End Sub
End Class
还有我的HTML:
<form id="form1" runat="server">
<div>
<label for="FullName">Full Name:</label>
<asp:TextBox ID="txtName" runat="server"/>
<label for="Comments">Comments:</label>
<asp:TextBox ID="txtComments" runat="server"/>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Send" /></div>
那你可以这样做,
myMailMessage.Body = txtName.Text+",\n"+txtComments.Text;
我已经成功发送了一封附有 CV/Resume 附件的电子邮件,但是如何在要在电子邮件中显示的表单中添加其他字段(全名和评论)。
我的 aspx.vb 中有以下代码:
Imports System.Net.Mail
Imports System.IO
Partial Class Default_VB
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If FileUpload1.HasFile Then
Dim toAddress As String = "email@address.com"
Dim fromAddress As String = "email@anotheraddress.com"
Dim mailServer As String = "smtp.1and1.com"
Dim myMailMessage As MailMessage = New MailMessage()
myMailMessage.To.Add(toAddress)
myMailMessage.From = New MailAddress(fromAddress)
myMailMessage.Subject = "Test Message"
Dim fileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
Dim myAttachment As New Attachment(FileUpload1.FileContent, fileName)
myMailMessage.Attachments.Add(myAttachment)
Dim mySmtpClient As New SmtpClient(mailServer)
mySmtpClient.Send(myMailMessage)
End If
End Sub
End Class
还有我的HTML:
<form id="form1" runat="server">
<div>
<label for="FullName">Full Name:</label>
<asp:TextBox ID="txtName" runat="server"/>
<label for="Comments">Comments:</label>
<asp:TextBox ID="txtComments" runat="server"/>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Send" /></div>
那你可以这样做,
myMailMessage.Body = txtName.Text+",\n"+txtComments.Text;