熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

Web上利用System.Web.Mail發送EMail

2013-11-13 10:25:56  來源: .NET編程 

  這是個的例子~

  Emailaspx

  <%@ Page Language=vb AutoEventWireup=false Codebehind=Emailaspxvb Inherits=asifSendEmail%>

  <!DOCTYPE HTML PUBLIC //WC//DTD HTML Transitional//EN

  <HTML>

  <HEAD>

  <title>SendEmail</title>

  <meta name=vs_showGrid content=True

  <meta content=Microsoft Visual StudioNET name=GENERATOR

  <meta content=Visual Basic name=CODE_LANGUAGE

  <meta content=JavaScript name=vs_defaultClientScript

  <meta content= name=vs_targetSchema

  </HEAD>

  <body MS_POSITIONING=GridLayout

  <form id=Form method=post runat=server

  <asp:Label id=Label runat=server Width=px FontSize=Large FontBold=True ForeColor=Blue

  >

  Sending Email from ASPNET WebPage

  </asp:Label>

  <asp:TextBox id=txtFrom runat=server Width=px

  </asp:TextBox>

  <asp:Label id=Label runat=server FontBold=True FontNames=Arial FontSize=Smaller

  From:

  </asp:Label>

  <asp:RequiredFieldValidator id=RequiredFieldValidator runat=server FontSize=XSmall

  ErrorMessage=*RequiredField ControlToValidate=txtFrom

  </asp:RequiredFieldValidator>

  <asp:TextBox id=txtTo runat=server Width=px

  </asp:TextBox>

  <asp:Label id=Label runat=server FontBold=True FontNames=Arial FontSize=Smaller

  >

  To:

  </asp:Label>

  <asp:RequiredFieldValidator id=RequiredFieldValidator runat=server FontSize=XSmall

  ErrorMessage=*RequiredField ControlToValidate=txtTo

  </asp:RequiredFieldValidator>

  <asp:TextBox id=txtSubject runat=server Width=px

  </asp:TextBox>

  <asp:Label id=Label runat=server FontBold=True FontNames=Arial FontSize=Smaller

  >

  Subject:

  </asp:Label>

  <asp:RequiredFieldValidator id=RequiredFieldValidator runat=server FontSize=XSmall

  ErrorMessage=*RequiredField ControlToValidate=txtSubject

  </asp:RequiredFieldValidator>

  <asp:TextBox id=txtMessage runat=server TextMode=MultiLine Width=px Height=px

  >

  </asp:TextBox>

  <asp:Label id=Label runat=server FontBold=True FontNames=Arial FontSize=Smaller

  >

  Message:

  </asp:Label>

  <asp:RequiredFieldValidator id=RequiredFieldValidator runat=server FontSize=XSmall ErrorMessage=*RequiredField ControlToValidate=txtMessage

  </asp:RequiredFieldValidator>

  <asp:Button id=cmdSendEmail runat=server Text=Send Email Width=px FontBold=True

  >

  </asp:Button>

  <asp:Label id=lblMessage runat=server

  FontSize=Small Width=px Visible=False

  </asp:Label>

  </form>

  </body>

  </HTML>

  Emailaspxvb

  Imports SystemWebMail

  Public Class SendEmail

  Private Sub cmdSendEmail_Click(ByVal sender As SystemObject ByVal e As SystemEventArgs) Handles cmdSendEmailClick

  Dim objMail As New MailMessage()

  objMailFrom = MetxtFromTextToString

  objMailTo = MetxtToTextToString

  objMailSubject = MetxtSubjectTextToString

  objMailBody = MetxtMessageTextToString

  objMailBodyFormat = MailFormatHtml

  SmtpMailSend(objMail)

  MelblMessageText = Email has been sent

  End Sub

  End Class


From:http://tw.wingwit.com/Article/program/net/201311/13600.html
    推薦文章
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.