Jul 29

Today I came across someone who was having trouble sending email from their ASP.net webpage, so I decided to create a little example of how to do so.

Step 1:
Before you can use my coding you must add my Send_Mail() method to your page’s behind the scenes class. To do this, right click on your .aspx page in your Solution Explorer, and select “View Code”. Once in this window, scroll to the very body, and right above “End Class“, paste the following:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
''' <summary>
''' This will allow you to send email in one simple sub call
''' </summary>
'''<param name="smtp_username">The login for your SMTP server. Ussualy same as your pop3 login</param>
'''<param name="smtp_password">The password for your SMTP server, ussualy same as your pop3 password</param>
'''<param name="smtp_server">The mail server to send to. Ussualy mail.yourdomain.com</param>
'''<param name="smtp_port">The port for your smtp server. More than likely always 25</param>
'''<param name="mail_from">Who to send mail from. For alot of servers (including smarter mail) this must be same as smtp_username</param>
'''<param name="mail_to">Who we are sending the mail to</param>
'''<param name="mail_subject">What your mail subject will be</param>
'''<param name="mail_body">What your mail body will be, HTML enabled</param>
''' <remarks>created by www.CoderGuru.com</remarks>
Public Sub Send_Mail(ByVal smtp_username As String, ByVal smtp_password As String, ByVal smtp_server As String, ByVal smtp_port As String, ByVal mail_from As String, ByVal mail_to As String, ByVal mail_subject As String, ByVal mail_body As String)
 
  'Dont edit anything below here unless you want BCC, simply uncomment my line
  Dim mail As New System.Net.Mail.MailMessage(mail_from, mail_to)
  mail.Subject = mail_subject
  mail.IsBodyHtml = True
  mail.Body = mail_body
  'mail.Bcc.Add("you_get_copy_too@foo.bar") 'Uncomment to add BCC's to this message
 
  Dim smtp As New System.Net.Mail.SmtpClient(smtp_server, smtp_port)
  Dim nc As New System.Net.NetworkCredential(smtp_username, smtp_password)
  smtp.Credentials = nc
  smtp.Send(mail)
 
End Sub

Step 2:
Once you have the method loaded, in your send button paste the following and fill in the fields needed:

1
2
3
4
5
6
7
8
9
10
11
12
  'Below holds your SMTP login information
  Dim smtp_username As String = "username here"
  Dim smtp_password As String = "password here"
  Dim smtp_server As String = "mail.yourdomain.com"
  Dim smtp_port As Integer = 25'Will more than likely never change
 
  Dim mail_from As String = smtp_username' For me my login is my email so simply reference that string
  Dim mail_to As String = "some_Email@somedomain.com"
  Dim mail_subject As String = "Hello World!"
  Dim mail_body As String = "look mom, my email holds <b>html</b> =0"
 
  Send_Mail(smtp_password, smtp_password, smtp_server, smtp_port, mail_from, mail_to, mail_subject, mail_body)

Check back soon for a working example in both VB.net and C#

Jul 28

To go along with my “Disabling / switching keys on your keyboard” post, I also was asked how to disable the windows task manager so that potential users could not turn off the computer or close down any running applications. This was a bit tricky, but after some googling, I was able to come across a built in setting for windows that does just this.

By default Windows doesn’t have access to this setting just sitting around for you to turn on and off, but with a little registry modifications, it can easily be done. The key you are looking to modify is inside [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System] and is called [DisableTaskMgr]. If you want your task manager off you simply set the dword Hexadecimal value to to “1″, and to re-enable it, simply clange it back to 0. Note that the first time you do this, you will more than likely have to create both the “System” folder and “DisableTaskMgr” key.

Don’t know how to work with the registry? Don’t worry, no research needed! Below is a zip file containing two different registry (.reg) files that you can download to automatically handle this! All you do is simply run the file and after you confirm you want to execute the file, your task manager will be set to the settings of your choice.

Enable / Disable Windows Task Manager (Alt+Ctrl+Del)

It’s that simple! Again, I hope I was able to save some of you guys the time I spent researching this.

Jul 28

Have you ever wanted to disable certain keys on your keyboard but have no idea how? After hours of searching, I managed to find a simple way to do such a task, and it works like a charm.

Now like most programmers, I figured “Hey I can probably just stop the keys from occurring in Visual Basic by hijacking the keyboard and only passing on the keys I wanted.” Well this did not work as well as I hoped, so I decided I would ask my ultimate source for knowledge, good old Google. After a few hours of searching different senerios, I finally came across just want I wanted! The Windows Server 2003 Resource Kit Tools.

Now the Windows Server 2003 Resource Kit Tools is a extremely large package packed with many different useful tools, but the tool that will come in handy today is called a crafty little application called “Remap” created by Microsoft.

By using remap, you have full access to “Remap” each and every keyboard key to a different key. Now why is this useful? Well it allows us to change the keys users could use to close our application and replace them with “SHIFT”. We went one step futhor and disabled almost any key combination that could be used to do anything we did not want such as ALT+TAB (switch window), CTRL+F2 (close window), ESCAPE (closes flash presentation), and Windows keys. To make it easy, we simply replaced each and every key we did not want with the Shift key, since the Shift key posed us no harm.

Disabling / switching keys on your keyboard
Disabling / switching keys on your keyboard

To use remap your keyboard, follow these simple steps: (how-to video at bottom)

  1. Download the Windows Server 2003 Resource Kit Tools from Microsofts website by clicking here.
  2. Once your download is complete, run “rktools.exe” which will install a whole bunch of tools for you to explore.
  3. Goto Start -> Run -> and type “remapkey.exe” inside the open text box. Then press OK
  4. At this point, Remapkey will open up, displaying the window to the left. The top “Base keyboard” is how your keyboard would be by default. The “Remapped keyboard” is how it will be after. Simply drag and drop the keys from your “Base Keyboard” into the possition you want on your Remapped Keyboard. In our example, we dragged “Shift” from the top to the “Esc” key on the bottom.
  5. When you have your keys exactly as you want them, simple click on the first icon below file remapkey_save to save your changes. It will ask you to confirm your changes and a reboot will be required.
  6. Once you have rebooted, your computer will now work as if your keyboard was setup just as you choose. You can go back to this program at any time to change your keyboard back.

Hope this helps some of you out so you don’t have to spend as much time as I did researching how to stop keystrokes from happening =]

Jun 16

Welcome to the new ChillAxen.com. For all who remember, ChillAxen was a social networking site based out of Buffalo NY that ran between March 2005 to September 2007. Despite consistant growth, I unfortunitely had to close the site down, but I am now happy to say I am once again making use of the site by hosting a person web blog!

My blog will basically focus around the computer technologies I use daily, including PHP, ASP.net, and windows, though we will cover other topics. I will do my best to update this site as much as possible, and urge you to help contribute and spread the word.

Looking forwards to watching this site once again grow as it did before,

~ Anthony F Greco ~

preload preload preload