|
|
|
Friday, 30 December 2011 03:42 |
// Send mail
private void SendMailFromMyCode()
{
MailMessage msg= new MailMessage();
msg.To.Add("
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
");
msg.Bcc.Add("
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
");
msg.Subject = Subject; // Specify subject , here it is variable
msg.From = new MailAddress("
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
");
msg.Body = HttpUtility.HtmlDecode(strMessage); // strMessage is a variable that has message ibody
msg.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
System.Net.NetworkCredential AuthInfo = new System.Net.NetworkCredential("
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
", "secret");
smtp.Host = strSMTPServer; // smtp.gmail.com
smtp.UseDefaultCredentials = false;
smtp.Credentials = AuthInfo;
smtp.Timeout = 20;
smtp.Port = 547;
smtp.EnableSsl = false;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Send(objMessage);
}
 Read more: |
|
|
Monday, 26 December 2011 00:23 |
A JavaScript alert is a simple window containing a message.
Here is what the code looks like — it's just one line (inside the JavaScript tag):
The text inside the parentheses is what is shown in the alert message. If you want to show a string of literal text, enclose the text in quotes. To display variable values, enter the variable name without quotes. You can also combine variable values and text strings by using the + sign. For example:
function showAlert() {
var country = "Fiji";
var city = "Suva";
alert('The city of ' + city + ' is located in ' + country + '.');
}
 Read more: |
|
Saturday, 19 June 2010 17:30 |
Source: instance_variable_get (Object) [apidock.com]
Returns the value of the given instance variable, or nil if the instance variable is not set. The @ part of the variable name should be included for regular instance variables. Throws a NameError exception if the supplied symbol is not valid as an instance variable name.
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
end
fred = Fred.new('cat', 99)
fred.instance_variable_get(:@a) #=> "cat"
fred.instance_variable_get("@b") #=> 99
*update: 19-Jun-2010 @ 7:40pm*
Here's another example:
class Fred
def initialize(p1, p2)
@a, @b = p1, p2
end
def list_instance_variables
vars = self.instance_variables
vars.map{|x| "%s: %s" % [x,self.instance_variable_get(x)]}
end
end
fred = Fred.new('cat', 99)
fred.list_instance_variables
#=> ["@a: cat", "@b: 99"]
 Read more: |
|
|
Friday, 28 May 2010 15:17 |
A class variable (@@variable) is referenced within the context of any object instantiated from the 1 class, wheres a class instance variable (self.class.variable) is referenced from the class object itself.
class variable example copied from Class: Module [ruby-doc.org]
class One
@@var1 = 1
end
class Two < One
@@var2 = 2
end
One.class_variables #=> ["@@var1"]
Two.class_variables #=> ["@@var2", "@@var1"]
class instance variable example copied from Ruby Programming/Syntax/Classes - Wikibooks ... [wikibooks.org]
class Employee
class << self; attr_accessor :instances; end
def store
self.class.instances ||= []
self.class.instances << self
end
def initialize name
@name = name
end
end
class Overhead < Employee; end
class Programmer < Employee; end
Overhead.new('Martin').store
Overhead.new('Roy').store
Programmer.new('Erik').store
puts Overhead.instances.size # => 2
puts Programmer.instances.size # => 1
 Read more: |
|
|
|
|
|