post your comment   print   send to a friend
Rate:   0% | Views: 883
Question categories:  NT Plans

How can i send emails using an asp.net script(.aspx) with my windows-based shared hosting plan?

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:

Customer Feedback
Rate:   0% | Views: 883 | Please Rate:  
 
If you have other comments or ideas for future technical tips, please type them here:

Email: (optional)

Comments: (optional)

 Email Hosting | Server Hosting    Back to serch results
Browse the Base
Knowledge Base
Shared Hosting
  NT Plans
Messages
 

$75 Free Google AdWords

Free $75 Google AdWords when you sign up for WebImage! Target by location, create your own, or let Google create your ads for you. Check out http://www.aplus.net/google.html to see how AdWords works for you.

Private Area
 
Ask
in Private
   
Personal
Folder
 
Related Questions
 
1. How can I connect to a Microsoft Access database using ASP?
 
2. How do I access the SQL Server that comes with my Windows hosting plan?
 
3. Some of the asp pages in my site use ASPEmail or CDONTS mail components but they don't work.
 
4. How do I enable SQL on my Windows plan using Aplus.Net web Control Panel?
 
5. What do i need to do to get an ASP.NET project to work?
 
Home Browse Search Ask in Private Personal Folder   Help
powered by web hosting 
  Logged as: Guest