使用System.Web.Mail類發送郵件:
 
<%@ Import Namespace="System.Web.Mail" %>
<script language="VB" runat="server">
 
  Sub btnSubmit_OnClick(sender as Object, e as EventArgs)
    'Send an email address with product information
    Dim objMessage as New MailMessage
 
    objMessage.BodyFormat = MailFormat.HTML
    objMessage.To = txtEmail.Text & " (" & txtName.Text & ")"
    objMessage.From = "[email protected] (Product Information)"
    objMessage.Headers.Add("Reply-To", "[email protected]")
    objMessage.Priority = MailPriority.High
    objMessage.Subject = "Product Information Request"
    
    objMessage.Body = "<i>Hello " & txtName.Text & "</i>!  To learn more about our " & _
                      "various products, visit the following URLs:<p><ul>" & _
                      "<li><a href=""http://www.acme.com/Widgets.htm"">Widgets</a>" & _
                      "<li><a href=""http://www.acme.com/DooHickies.htm"">DooHickies</a>" & _
                      "<li><a href=""http://www.acme.com/TAMB.htm"">Thning-a-ma-Bobs</a>" & _
                      "</ul><p> If you have any " & _
                      "questions, please simply reply to this email!<p><hr><p>" & _
                      "<font color=red size=-1><i>Thank you for choosing Acme!</i></font>"
     'Send the message
    SmtpMail.Send(objMessage)
 
    'Display notification of mail being sent
    Response.Write("<font color=red><b>You have been sent " & _
                   "product information!  Thank you!</b></font>")
  End Sub
 
</script>
 
<html>
<body>
 
  <form method=post runat=server>
 
    <h1>Information Request</h1>
    <b>Your Name:</b>
    <asp:textbox id="txtName" runat="server" /><br>
    <b>Your Email Address:</b>
    <asp:textbox id="txtEmail" runat="server" /><p>
 
    <asp:button id="btnSubmit" runat="server" OnClick="btnSubmit_OnClick"
                text="Send me Product Information" />
  </form>
 
</body>
</html>

解决方案 »

  1.   


    string mailBody=ds_company.get_company+" 招聘信息:<br>"+ds_company.get_info+"<br>"; MailMessage myMessage=new MailMessage();
    myMessage.From=cs_person.get_Email;
    myMessage.To=tb_Email.Text;
    //高优先级邮件
    myMessage.Priority=System.Web.Mail.MailPriority.High;
    myMessage.Subject=cs_person.get_Email+"发送的招聘信息";
    myMessage.Body=mailBody; myMessage.BodyFormat=MailFormat.Html;
    //SmtpMail.SmtpServer="61.129.112.205";
    //SmtpMail.SmtpServer="localhost";

    SmtpMail.Send(myMessage);
    Response.Write ("<script>window.alert('您需要的招聘信息已经发送到指定信箱!')</script>");