0

ユーザーが友達にメンバーシップを紹介できる紹介フォームがあります。フォームアクションはaspファイルを指している必要があります。(私はphpで開始し、別のサーバーで動作させましたが、配置する必要のあるサーバーはaspである必要があります)。検索して検索しましたが、いくつか問題があります。(私はasp初心者です)

  1. フォームはユーザーにメールを送信する必要があります。私はこれをここのaspファイル(email.asp)で動作させました:

    <%
    Dim senderName, senderEmail, senderMessage
    Dim name1, name2, name3, name4, name5, name6, name7, name8, name9, name10
    Dim email1, email2, email3, email4, email5, email6, email7, email8, email9, email10
    senderName = Request.Form("senderName")
    senderEmail = Request.Form("senderEmail")
    senderMessage = Request.Form("senderMessage")
    name1 = Request.Form("name1")
    name2 = Request.Form("name2")
    name3 = Request.Form("name3")
    name4 = Request.Form("name4")
    name5 = Request.Form("name5")
    name6 = Request.Form("name6")
    name7 = Request.Form("name7")
    name8 = Request.Form("name8")
    name9 = Request.Form("name9")
    name10 = Request.Form("name10")
    email1 = Request.Form("email1")
    email2 = Request.Form("email2")
    email3 = Request.Form("email3")
    email4 = Request.Form("email4")
    email5 = Request.Form("email5")
    email6 = Request.Form("email6")
    email7 = Request.Form("email7")
    email8 = Request.Form("email8")
    email9 = Request.Form("email9")
    email10 = Request.Form("email10")   
    
    'Sends an email
    Dim mail
    Set mail = Server.CreateObject("CDO.Message")
    'for testing i am only sending to the first email
    mail.To = email1
    mail.From = senderEmail
    mail.Subject = "Join Dallas Cowboys True Blue Fan Club with me!"
    mail.TextBody = "Join Dallas Cowboys True Blue Fan Club with me!"
    mail.Send()
    Response.Write("Mail Sent!")
    'Destroy the mail object!
    Set mail = nothing
    %>
    
  2. 最後に、フォームデータをcsvファイルに追加する作業用aspxファイル(append.aspx )があります。私が抱えている本当の問題は、両方のファイルを1つの作業ファイルに結合することです。

    <%@ Import Namespace="System.IO" %>
    <script type="text/javascript">
    window.onload = window.close();
    </script>
    <script language="vb" runat="server">
    sub Page_Load(sender as Object, e as EventArgs)
    'Open a file for writing
    Dim FILENAME as String = Server.MapPath("Output.csv")
    
    Dim senderName, senderEmail, senderMessage
    Dim name1, name2, name3, name4, name5, name6, name7, name8, name9, name10
    Dim email1, email2, email3, email4, email5, email6, email7, email8, email9, email10
    senderName = Request.Form("senderName")
    senderEmail = Request.Form("senderEmail")
    senderMessage = Request.Form("senderMessage")
    name1 = Request.Form("name1")
    name2 = Request.Form("name2")
    name3 = Request.Form("name3")
    name4 = Request.Form("name4")
    name5 = Request.Form("name5")
    name6 = Request.Form("name6")
    name7 = Request.Form("name7")
    name8 = Request.Form("name8")
    name9 = Request.Form("name9")
    name10 = Request.Form("name10")
    email1 = Request.Form("email1")
    email2 = Request.Form("email2")
    email3 = Request.Form("email3")
    email4 = Request.Form("email4")
    email5 = Request.Form("email5")
    email6 = Request.Form("email6")
    email7 = Request.Form("email7")
    email8 = Request.Form("email8")
    email9 = Request.Form("email9")
    email10 = Request.Form("email10")   
    
    'Get a StreamWriter class that can be used to write to the file
    Dim objStreamWriter as StreamWriter
    objStreamWriter = File.AppEndText(FILENAME)
    
    'AppEnd the the End of the string, "A user viewed this demo at: "
    'followed by the current date and time
    objStreamWriter.WriteLine(sEnderName & "," & sEnderEmail & "," & name1 & "," & email1 & "," & senderMessage & "," & DateTime.Now.ToString())
    If name2 <> "" then
    objStreamWriter.WriteLine("," & "," & name2 & "," & email2)
    End If
    If name3 <> "" then
    objStreamWriter.WriteLine("," & "," & name3 & "," & email3)
    End If
    If name4 <> "" then
    objStreamWriter.WriteLine("," & "," & name4 & "," & email4)
    End If
    If name5 <> "" then
    objStreamWriter.WriteLine("," & "," & name5 & "," & email5)
    End If
    If name6 <> "" then
    objStreamWriter.WriteLine("," & "," & name6 & "," & email6)
    End If
    If name7 <> "" then
    objStreamWriter.WriteLine("," & "," & name7 & "," & email7)
    End If
    If name8 <> "" then
    objStreamWriter.WriteLine("," & "," & name8 & "," & email8)
    End If
    If name9 <> "" then
    objStreamWriter.WriteLine("," & "," & name9 & "," & email9)
    End If
    If name10 <> "" then
    objStreamWriter.WriteLine("," & "," & name10 & "," & email10)
    End If
    'Close the stream
    objStreamWriter.Close()
    End sub
    </script>
    
4

1 に答える 1

1

System.Net.MailmessageとSmtpClientを使用する必要があります。

http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage.aspx

于 2012-05-24T17:04:07.753 に答える