我有一个联系表格(VS 2010 / VB / .net4),当客户填写表格时,我会收到一封电子邮件——我喜欢,但是....
例如,这是我收到的一封电子邮件:
电子邮件:ivy_league_alum-at-yahoo.com
主题:你们会整合PPT吗?
留言:我正在寻找密歇根地区的PPT集成商。
名字:蒂姆
姓氏:杜瓦
组织:美国车桥
浏览器:Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7
IP地址:184.60.79.96
服务器日期和时间:2012 年 1 月 13 日上午 11:28:59
这只是一家产生潜在客户的公司,所以我们会收到很多电子邮件,我们会希望它们井井有条。
Jon P 建议我使用数据库来收集我收到的所有这些电子邮件,而不是 MS Excel(反正我不知道该怎么做)。所以我下载了 SQL Server Express。那么现在我该怎么办?有人可以告诉我我必须在代码中添加什么,或者我必须做什么,以便我可以有组织地收集这些电子邮件吗?谢谢!
附录(我知道这很长):
具体来说,我的电子邮件代码是:
<%@ Page Title="Contact Health Nutts" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="contact.aspx.vb" Inherits="contact" %> Protected Sub SubmitForm_Click( ByVal sender As Object, ByVal e As System.EventArgs) If Not Page.IsValid Then Exit Sub
Dim SendResultsTo As String = "jason.weber-at-healthynutts.com" Dim smtpMailServer As String = "smtp.healthynutts.com" Dim smtpUsername As String = "jason.weber-at-healthynutts.com" Dim smtpPassword As String = "********" Dim MailSubject As String = "Form Results" Try Dim txtQ As TextBox = Me.FormContent.FindControl("TextBoxQ") If txtQ IsNot Nothing Then Dim ans As String = ViewState("hf1") If ans.ToLower <> txtQ.Text.ToLower Or ans.ToUpper <> txtQ.Text.ToUpper Then Me.YourForm.ActiveViewIndex = 3 Exit Sub End If End If Dim FromEmail As String = SendResultsTo Dim msgBody As StringBuilder = New StringBuilder() Dim sendCC As Boolean = False For Each c As Control In Me.FormContent.Controls Select Case c.GetType.ToString Case "System.Web.UI.WebControls.TextBox" Dim txt As TextBox = CType(c, TextBox) If txt.ID.ToLower <> "textboxq" Then msgBody.Append(txt.ID & ": " & txt.Text & vbCrLf & vbCrLf) End If If txt.ID.ToLower = "email" Then FromEmail = txt.Text End If If txt.ID.ToLower = "subject" Then MailSubject = txt.Text End If Case "System.Web.UI.WebControls.CheckBox" Dim chk As CheckBox = CType(c, CheckBox) If chk.ID.ToLower = "checkboxcc" Then If chk.Checked Then sendCC = True Else msgBody.Append(chk.ID & ": " & chk.Checked & vbCrLf & vbCrLf) End If Case "System.Web.UI.WebControls.RadioButton" Dim rad As RadioButton = CType(c, RadioButton) msgBody.Append(rad.ID & ": " & rad.Checked & vbCrLf & vbCrLf) Case "System.Web.UI.WebControls.DropDownList" Dim ddl As DropDownList = CType(c, DropDownList) msgBody.Append(ddl.ID & ": " & ddl.SelectedValue & vbCrLf & vbCrLf) End Select Next msgBody.AppendLine() msgBody.Append("Browser: " & Request.UserAgent & vbCrLf & vbCrLf) msgBody.Append("IP Address: " & Request.UserHostAddress & vbCrLf & vbCrLf) msgBody.Append("Server Date & Time: " & DateTime.Now & vbCrLf & vbCrLf) Dim myMessage As System.Net.Mail.MailMessage = New System.Net.Mail.MailMessage() myMessage.To.Add(SendResultsTo) myMessage.From = New System.Net.Mail.MailAddress(FromEmail) myMessage.Subject = MailSubject myMessage.Body = msgBody.ToString myMessage.IsBodyHtml = False If sendCC Then myMessage.CC.Add(FromEmail) Dim basicAuthenticationInfo As New System.Net.NetworkCredential(smtpUsername, smtpPassword) Dim MailObj As New System.Net.Mail.SmtpClient(smtpMailServer) MailObj.Credentials = basicAuthenticationInfo MailObj.Send(myMessage) Me.YourForm.ActiveViewIndex = 1 Catch Me.YourForm.ActiveViewIndex = 2 End Try End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If Not Page.IsPostBack Then Dim lbl As Label = Me.FormContent.FindControl("labelq") If lbl IsNot Nothing Then Dim rq(3) As String rq(0) = "Is fire hot or cold?" rq(1) = "Is ice hot or cold?" rq(2) = "Is water wet or dry?" Dim ra(3) As String ra(0) = "hot" ra(1) = "cold" ra(2) = "wet" Dim rnd As New Random Dim rn As Integer = rnd.Next(0, 3) lbl.Text = rq(rn) ViewState("hf1") = ra(rn) End If End If End Sub </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server"> <h1>CONTACT HEALTH
在自己舒适的家中疯狂工作!
输入您的电子邮件地址:
* 必填 * 请输入有效的电子邮件地址。
主题:
* 必填
请在下面输入您的信息: * 必填
名字:
* 必填
姓氏:
* 必填
电话号码:
* 必填 * 请输入有效的美国电话号码(包括破折号)。
城市:
* 要求的
州/省:
* 必填
您的信息已发送。感谢您与我们联系。
由于技术困难,您的消息可能尚未发送。您没有正确回答反垃圾邮件问题。请返回重试。