If server is unsecure dont need SMTP credentials or SSL enabled.
For example if using google:
SMTP = smtp.gmail.com
credentialsUN = johnilett@gmail.com
credentialsPW = YOURPASSWORD
returnEmail = noreply@gmail.com - Dummy
using System.Net.Mail;
protected void mail(string email, string name)
{
getCredentials();
MailMessage mail = new MailMessage();
mail.To.Add(email);
mail.From = new MailAddress(credentialsUN);
mail.ReplyTo = new MailAddress(credentialsUN);
mail.Subject = "HR DW Website Password";
mail.IsBodyHtml = true;
string Body = "<~html~><~/body~>Dear " + name + "," + "<~br /~>" + "<~br /~>" + "Your password for the HR DW website is: " + "" + "<~b~>" + password + "<~/b~>";
Body += "<~br /~>" + "<~br /~>" + "Thanks," + "<~br /~>" + "HR DW Support.<~/body~><~/html~>";
mail.Body = Body;
SmtpClient smtp = new SmtpClient();
smtp.Host = credentialsSMTP;
//Dont need these 2 if unsecure SMTP
smtp.Credentials = new System.Net.NetworkCredential(credentialsUN, credentialsPW);
smtp.EnableSsl = true;
smtp.Send(mail);
}
*replace ~ with ""
Friday, 27 November 2009
asp .net: Creating NameSpace
Step 1: Creating Namespace class in App_Code (cs or vb)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace YOURNAMESPACENAME
{
///
/// Summary description for of Class
///
public class YOURCLASSNAME
{
//METHODS AND VALUES - PUBLIC
}
}
Step 2: Calls your namespace in aspx.cs class
using YOURNAMESPACENAME;
create new object in Main class for YOURCLASSNAME -
YOURCLASSNAME ClassName = new YOURCLASSNAME ();
Now call your methods and values, etc:
ClassName.MethodName()
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace YOURNAMESPACENAME
{
///
/// Summary description for of Class
///
public class YOURCLASSNAME
{
//METHODS AND VALUES - PUBLIC
}
}
Step 2: Calls your namespace in aspx.cs class
using YOURNAMESPACENAME;
create new object in Main class for YOURCLASSNAME -
YOURCLASSNAME ClassName = new YOURCLASSNAME ();
Now call your methods and values, etc:
ClassName.MethodName()
Wednesday, 11 November 2009
ASP: gridview delete confirmation box
...
Text="Delete" />
Tuesday, 3 November 2009
Javascript: Confirm logout and save document
function closeWindow() {
if (confirm('Are you sure you would like to logout?')) {
//document.forms['form1'].submit();
window.open('', '_self');
window.close();
};
}
if (confirm('Are you sure you would like to logout?')) {
//document.forms['form1'].submit();
window.open('', '_self');
window.close();
};
}
Subscribe to:
Posts (Atom)