Pages

Friday, June 18, 2010

Email Sending Function

Namespace :
using System.Net.Mail;

Function # 1:

public void SendEmail
_ByHostSettings(string mySubject,string myMessageBody,string Email_To)
{
MailMessage mm = new MailMessage(Convert.ToString(DotNetNuke.Common.Globals.HostSettings["HostEmail"]), Email_To, mySubject, myMessageBody);
mm.BodyEncoding = System.Text.Encoding.UTF8;
mm.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient(Convert.ToString(DotNetNuke.Common.Globals.HostSettings["SMTPServer"]));

if (DotNetNuke.Common.Globals.HostSettings["SMTPEnableSSL"].ToString() == "Y")
{
smtp.EnableSsl = true;
}
else
{
smtp.EnableSsl = false;
}

smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(Convert.ToString(DotNetNuke.Common.Globals.HostSettings["SMTPUsername"]), Convert.ToString(DotNetNuke.Common.Globals.HostSettings["SMTPPassword"])); //From user credentails
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

smtp.Send(mm);

}


Function # 2:

public void SendEmail(string mySubject, string myMessageBody, string Email_To, string Email_From, string SMTPServer, bool EnableSsl, string SMTPUsername, string SMTPPassword)
{
MailMessage mm = new MailMessage(Email_From, Email_To, mySubject, myMessageBody);
mm.BodyEncoding = System.Text.Encoding.UTF8;
mm.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient(SMTPServer);

smtp.EnableSsl = EnableSsl;

smtp.UseDefaultCredentials = false;
smtp.Credentials = new System.Net.NetworkCredential(SMTPUsername,SMTPPassword);
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

smtp.Send(mm);

}

How to Call:

new SendEmail_ByHostSettings("TEST MAIL", "Thanks for your interest", "razarajwani@live.com");

DNN Parametrized Redirection

Function :

public string GetTabIDURL(int PortalID, string ModuleName)
{ DataTable dt = new udf.Udf().Fill_DataTable("SELECT * FROM vw_Modules where modulename='" + ModuleName + "' and portalid=" + PortalID + " and tabid is not null");

return "~/tabid/" + dt.Rows[0]["tabid"].ToString() + "/default.aspx";

}


How to Call:

protected void GoToDetail_Click(object sender, EventArgs e)
{
int JobID = Convert.ToInt32((((LinkButton)sender).CommandArgument));

Response.Redirect(new udf.Udf().GetTabIDURL(this.PortalId, "bl_JobDisplay").ToString() + "?JobID=" + JobID);

}

Wednesday, June 16, 2010

Autocomplete text box in dot net nuke

This article define how you will use the text suggestion box in dot net nuke like google, msn or yahoo websites

read this
http://www.dotnetnuke.com/Community/Blogs/tabid/825/EntryId/1067/Using-the-DNN-Text-Suggest-Control.aspx


Styles for Text suggestion Boxes
http://woork.blogspot.com/2009/02/useful-ajax-auto-suggest-scripts

HTML VS HTM

This is very simple question but i don't think many people knows about that what is the difference between HTML and HTM why these both extension are different even both contain the same code style

Ans. Three letter extension (.htm) was due to Windows 8.3 filenaming convention used in DOS because it could not understand 4 letter extensions or long filenames. html is the proper extension and should always try to use this instead of htm. in 1995 when windows 95 arrived then it will give the support for more then 3 charcter extenshion thats why .html was drived always prefer to use ".html"