Links
Calendar
<<  November 2008  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
Blogroll
Site statistics
Keywords
<script runat="server">
    protected string now = DateTime.Now.ToString();
    public void Page_Load(object sender, EventArgs e)
    {
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();

System.Net.NetworkCredential cred = new System.Net.NetworkCredential("yourid@gmail.com", "yourpassword");

mail.To.Add("a@a.com");
mail.Subject = "subject goes here";

mail.From = new System.Net.Mail.MailAddress(yourid@gmail.com);
mail.IsBodyHtml = true;
mail.Body = "This message has been sent programmatically with GMail";

System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("smtp.gmail.com");
smtp.UseDefaultCredentials = false;
smtp.EnableSsl = true;
smtp.Credentials = cred;
smtp.Port = 587;
smtp.Send(mail);
    }
</script>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Hi ,

 I find a solution for adding websites to IIS with asp.net, this is very amazing! the first step is adding Microsoft.Web.Administration.dll to your project's refrences, it is at "windir\system32\inetsrv\" folder.

 Here is the code:

C# version:

using System;

using Microsoft.Web.Administration;

class Program

{

static void Main(string[] args)

{

ServerManager mgr =
new ServerManager();

mgr.Sites.Add("MyWebSite", "http", "198.1.1.0:80:",

@"d:\MyWebSiteRootWebAppRootVirDir");

mgr.CommitChanges();

}

}

 VB.NET version:

Imports Microsoft.VisualBasic

Imports Microsoft.Web.Administration

Imports System.Configuration

Public Class clsCreateWebsite

Public Function createWebsite(ByVal websiteName As String, ByVal domainName As String, ByVal physicalPath As String) As Boolean

Dim IIS_manager As New ServerManager

Try

IIS_manager.Sites.Add(websiteName, "http", "*:80:" + domainName, physicalPath) IIS_manager.CommitChanges()

Return True

Catch ex As Exception

Return False

Finally

IIS_manager = Nothing

End Try

End Function

End Class

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5