Sri Lanka .NET 
                Forum Member

Tuesday, November 27, 2007

MP3 Players

Are you planning to buy a mp3 player and do you want to compare prices of different players provided by different companies. There is a very nice and good site which is called “save buckets” which you can use to do buy a mp3 player for your need. From this site you can compare latest prices of hundreds of mp3 players.

Tuesday, November 20, 2007

Acedamic Second Shot

Microsoft is providing a second shot offer for acedamic students. To get register for that offer please visit below link.

Register

Wednesday, November 14, 2007

Tuesday, November 13, 2007

Sending Newsletters using C# 2.0

1.Without using MSMQ

using System.Net.Mail;
using System.Data.SqlClient;
using System.Messaging;



2.With using MSMQ

//This function will send the message to the msmq if the server
//fails to send the email
private void sendNewsletterMSMQ()
{
if (MessageQueue.Exists(@".\private$\Newsletter") == false)
{
MessageQueue.Create(@".\private$\Newsletter");
}

MessageQueue objQue = new MessageQueue(@".\private$\Newsletter");

SqlConnection conn = new SqlConnection("server=localhost;uid=sa;pwd=password;database=Newsletters;");
SqlCommand comm = new SqlCommand("SELECT DISTINCT Email FROM NewsletterEmails", conn);

SqlDataReader dr;

MailAddress from;
MailAddress to;

SmtpClient objClient = new SmtpClient();

objClient.Host = "host";
objClient.Credentials = new System.Net.NetworkCredential("user name", "password");

try
{

conn.Open();

dr = comm.ExecuteReader(CommandBehavior.CloseConnection);

while (dr.Read())
{
from = new MailAddress("admin@admin.com");
to = new MailAddress(dr[0].ToString());

MailMessage objMail = new MailMessage(from, to);

objMail.Subject = "Newsletter";
objMail.IsBodyHtml = true;
objMail.Body = "HTML CODE";

try
{
objClient.Send(objMail);
}
catch
{
objQue.Send(objMail.To[0].Address.ToString());
}
}

dr.Close();
}
catch (SqlException sqlEx)
{
Response.Write("Database error: " + sqlEx.Message);
}
catch (Exception ex)
{
Response.Write("General error: " + ex.Message);
}
}


//This function will start reading the msmq
private void readMSMQ()
{
MessageQueue objQue = new MessageQueue(@".\private$\Newsletter");

string[] types = { "System.String" };
((XmlMessageFormatter)objQue.Formatter).TargetTypeNames = types;

objQue.ReceiveCompleted += new ReceiveCompletedEventHandler(queue_ReceiveCompleted);

objQue.BeginReceive();
}


//Event handler for the ReceiveCompleted event
private void queue_ReceiveCompleted(object sender, ReceiveCompletedEventArgs e)
{
try
{
string toAddress = e.Message.Body.ToString();

sendNewsletterMSMQ(toAddress);

AyuviQue.BeginReceive();

}
catch
{

}

}


//This function will send the email to the specified address
private void sendNewsletterMSMQ(string toAddress)
{
if (MessageQueue.Exists(@".\private$\Newsletter") == false)
{
MessageQueue.Create(@".\private$\Newsletter");
}

MessageQueue objQue = new MessageQueue(@".\private$\Newsletter");

MailAddress from;
MailAddress to;

SmtpClient objClient = new SmtpClient();

objClient.Host = "host";
objClient.Credentials = new System.Net.NetworkCredential("user name", "password");

try
{
from = new MailAddress("admin@admin.com");
to = new MailAddress(toAddress);

MailMessage objMail = new MailMessage(from, to);

objMail.Subject = "Newsletter";
objMail.IsBodyHtml = true;
objMail.Body = "HTML CODE";

try
{
objClient.Send(objMail);
}
catch
{
objQue.Send(objMail.To[0].Address.ToString());
}
}
catch (Exception ex)
{
Response.Write("General error: " + ex.Message);
}
}

Monday, November 12, 2007

American Green Card

U.S Department of States have opened the 2009 Diversity Visa Program (DV-2009) now. The people who wish you apply for this lottery can now submit their applications.

The application submission period for DV-2008 is from 12:00PM EDT (GMT -4) on October 3, 2007 to 12:00PM EST (GMT -5) on December 2, 2007.

If you are intrested apply now.It's totally free.

Apply