|
Answer
by: George Kaloyanov, Aplus.Net Knowledge Base Support
You
can send emails off the Windows shared hosting server using an ASP.NET
(.aspx) based webpage. In this document, we will present one
complete example of an ASP.NET script which can be used to
send out emails in HTML format.
Note:
ASP.NET is supported with the Personal
Windows, Business Class Windows,
Pro Windows
and eCommerce Windows
shared
hosting plans.
In
general, you will need to:
- import
the "System.Web.Mail" namespace.
- create
a MailMessage object.
- define
the properties of your MailMessage object (i.e: To, CC, From, Subject,
Body).
- define
the SMTP Server as "localhost".
- send
the email message.
Complete
ASP.NET Example:
<% @Page Language="C#" %>
<% @Import Namespace="System.Web.Mail" %>
<%
MailMessage MyMessage
= new MailMessage();
MyMessage.To = "recipient@example.com";
MyMessage.Cc = "another-recipient@example2.com";
MyMessage.From = "sender@yourdomain.com";
MyMessage.Subject = "Your Subject Here";
MyMessage.BodyFormat = MailFormat.Html;
string strBody =
"<html><body><b>Hi John, How
are you?</b>" +
" <font color=\"red\">This
is generated with
ASP.NET</font></body></html>";
MyMessage.Body = strBody;
SmtpMail.SmtpServer="localhost";
SmtpMail.Send(MyMessage);
Response.Write("Email successfully sent");
%>
Related
links:
|