ASP.NET sends an email routine:
<% @ page language = "c #" debug = "true" explicit = "true"
%>
<% @ Import namespace = "system.web.util"%>
<% @ Import namespace = "system.web.mail"%>
Public void sendmail (Object Obj, Eventargs E) {
LabelsendmailResult.text = "";
IF (page.isvalid) {
MailMessage Mailobj = New MailMessage ();
/ / Set the address of Email 'from' and 'to'
Mailobj.from = inputmailfrom.value;
Mailobj.to = inputmailto.value;
Mailobj.Subject = InputMailsUbject.Value;
Mailobj.Body = TextBoxmailBody.text;
// Optional: Email in HTML format
Mailobj.BodyFormat = mailformat.html;
// Optional: Encrypt mail
// mailobj.bodyencoding = mailformat.base64;
// Optional: Set the priority of the message is high
Mailobj.Priority = mailpriority.high;
// Optional: Accessories
IF (InputMaiLattachment.postedFile.ContentLength> 0) {
/ (Note that we have created a MaiLattachment object to attach a text
Part to Email.
Mailobj.attachments.Add (New
MaiLattachment (InputMailattachment.postedFile.FileName)
);
}
// Use the SMTPMAIL object to send an email.
SMTPMAIL.SEND (Mailobj);
LabelsendmailResult.text = "Mail sent success from:"
InputMailFrom.Value "; to:" InputMailto.value;
IF (InputMaiLattachment.postedFile.ContentLength> 0) {
LabelsendMailResult.text = "
This message contains attachments:"
InputMaiLattachment.postedFile.FileName ", the attachment size is
: " (InputMaiLattachment.postedFile.ContentLength /
1024) .toString () "k byte (s)";
}
}
}
script>
Send an email ASP.NET Title>
hEAD>