使用提交的表单数据发送电子邮件

时间:2013-05-23 21:21:04

标签: asp.net

我想在我的网站上创建一个表单,如果用户将其填写并发送,那么我会收到包含他的数据的确认电子邮件。我知道如何通过PHP实现它,但我只能使用ASP而且我不熟悉ASP。感谢您的建议和帮助。所以我的表格看起来像这样:

                  

                  <tr>
                    <td>*First Name: </td>
                    <td colspan="3"><input type="text" name="FirstName" required  id="field"/></td>
                  </tr>

                  <tr>
                    <td>*Last Name: </td>
                    <td colspan="3"><input type="text" name="LastName" required id="field" /></td>
                  </tr>

                  <tr>
                    <td>Company: </td>
                    <td colspan="3"><input type="text" name="Company" id="field" /></td>
                  </tr>

                  <tr>
                    <td>*Address: </td>
                    <td colspan="3"><input type="text" name="Address" required id="field" /></td>
                  </tr>

                  <tr>
                    <td align="left">*City: </td>
                    <td colspan="3"><input type="text" name="City" required id="field" /></td>
                  </tr>

                  <tr>
                    <td align="left">*State: </td>
                    <td colspan="3"><input type="text" name="State" required id="field" /></td>
                  </tr>

                  <tr>
                    <td align="left">*Zip Code: </td>
                    <td colspan="3"><input type="text" name="ZipCode" required id="field" /></td>
                  </tr>

                  <tr>
                    <td align="left">*Phone: </td>
                    <td><input type="text" name="lastname" required id="field" /></td>
                    <td>&nbsp;&nbsp;&nbsp;Ext. </td>
                    <td><input type="text" name="Extension" id="field-extensions"/></td>
                  </tr>

                  <tr>
                    <td align="left">Fax: </td>
                    <td><input type="text" name="Fax" id="field" /></td>
                  </tr>

                  <tr>
                    <td align="left">*Email: </td>
                    <td><input type="email" name="Email" required id="field" /></td>
                  </tr>

                  <tr>
                    <td colspan="4" align="left"><br /><br />Comments:<br />
                    <textarea rows="10" cols="120" id="field-comments" name="Comments"> </textarea><br />                      
                    <button type="submit" id="sub-button">Submit</button></td>                       
                  </tr>

                </table>

           </form>

1 个答案:

答案 0 :(得分:2)

假设您在ur表单中使用Post方法:在目标(操作页面)

执行以下操作

<%
Dim name, lastName, Company, Address, City
name = Request.Form("FirstName")
lastName= Request.Form("LastName")
Company= Request.Form("Company")
Address= Request.Form("Address")
City= Request.Form("City")
.....


Set myMail=CreateObject("CDO.Message")
myMail.Subject="user Iformation"
myMail.From="mymail@mydomain.com"
myMail.To="yourselef@somedomain.com"
myMail.TextBody="user information "& name & "lastName: " & lastName & .....(rest of params)
myMail.Send
set myMail=nothing

%>

问候