2010-02-23

Send Email By SMTP

Imports System.Net.Mail


Public
Sub SendEmail()

Dim client As New SmtpClient()
Dim sendTo As New MailAddress("sendToAccount@gmail.com")
Dim from As MailAddress = New MailAddress("from@address.com")
Dim
message As New MailMessage(from,sendTo)


message.IsBodyHtml = True
message.Subject = "Test SMTP"
message.Body = "Got it!!"

' Use the same account in app.config to authenticate.
Dim basicAuthenticationInfo As New System.Net.NetworkCredential("yourAccount@xxx.com", "YourPassword")


client.Host = "smtp.xxx.com"
client.UseDefaultCredentials = False

client.Credentials = basicAuthenticationInfo

'' For smtp config
'' google use EnableSsl=True and Port = 587

client.EnableSsl = False
client.Port = 25

Try

client.Send(message)
Console.WriteLine("SUCCESS")

Catch ex As Exception

Console.WriteLine("SEND FAIL")

End Try

End Sub

2010-02-22

Developer Books

Developer Books



Professional Visual Basic 2008 (Programmer to Programmer)

* Paperback: 1420 pages
* Publisher: Wrox (May 5, 2008)
* Language: English
* ISBN-10: 0470191368
* ISBN-13: 978-0470191361

Product Description
Professional Visual Basic 2008

The 2008 version of Visual Basic is tremendously enhanced and introduces dramatic new concepts, techniques, and features to this popular object-oriented language. Written by an elite author team who are sympathetic to the challenges of learning VB 2008, this comprehensive book provides a clear and concise approach to using VB 2008 in the ever-expanding .NET world.

This book focuses on using the latest and most powerful tools from the Microsoft arsenal within your Visual Basic solutions. Looking closely at LINQ, AJAX, a new Visual Studio and more, you'll be able to take lessons from this book and apply them to what you are doing today. You'll examine everything from the .NET Framework to the best practices for deploying .NET applications to database access and integrating with other technologies, such as COM and XML.

What you will learn from this book

* The core elements of VB 2008 as well as full syntax of all the new additions the language offers
* Ways that the Common Language Runtime (CLR) is responsible for managing the execution of code compiled on the .NET platform
* How VB is used in the creation, installation, running, and debugging of Windows? Services
* How to work with the new SQL Server 2008 along with your .NET applications
* The many features of Windows Forms and Windows Presentation Foundation
* Ways to take advantage of the abilities of LINQ
* The new web technology introduced by Silverlight

Who this book is for

This book is for experienced developers who are looking to transition to the latest version of Visual Basic.

Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.





Microsoft Visual Basic .NET Programmer's Cookbook (Pro-Developer)

Finally, a book with one-stop shopping for VB.NET! I’ve read several cookbook-style programming titles in the past, and I was pleasantly surprised to find this has much more depth than I expected. It can’t cover everything (.NET is huge), but every time I pick the book up I learn something new. There are so many highlights–just browse through the table of contents and you’ll see what I mean!
Here are some of my favorites:
* Send keystrokes to another app
* Create a thread-safe control wrapper
* Great data-binding tips (image-to-picture box, etc.)
* Factory, Registry, Singleton, Memento, and Lazy Initialization patterns
* POP3, FTP, and Ping classes in the networking section
* How to change a password into a salted hash for storage in a database
* Use ZIP and PDF files (disclaimer: some third-party code is required, although it’s free)
* Manage print jobs that are underway
* Get Windows accounts and roles
* Do hit testing with custom graphics
* Defend against SQL injection
* Dynamically generate an ASP.NET graphic
* Add ASP.NET controls on the fly
* MAPI and MCI (unfortunately, just through the ActiveX controls)
* Upload binary data with a web service
* Use a web service in VB 6

Written by cellphonereview on Dec-21-09 9:08pm
From: bestdp.com






Inside Microsoft SQL Server 2008: T-SQL Programming (Pro-Develper)

Product Description
Tackle the toughest set-based querying and query tuning problems—guided by an author team with in-depth, inside knowledge of T-SQL. Deepen your understanding of architecture and internals—and gain practical approaches and advanced techniques to optimize your code’s performance. Discover how to:
* Move from procedural programming to the language of sets and logic
* Optimize query tuning with a top-down methodology
* Assess algorithmic complexity to predict performance
* Compare data-aggregation techniques, including new grouping sets
* Manage data modification—insert, delete, update, merge—for performance
* Write more efficient queries against partitioned tables
* Work with graphs, trees, hierarchies, and recursive queries
* Plus—Use pure-logic puzzles to sharpen your problem-solving skills

2009-10-29

Show and Hide Windows Form in System Tray

How to show and hide your form in windows system tray.

1. Add NotifyIcon class in your project (System.Windows.Forms.NotifyIcon) and drag it into form.



2. Change NotifyIcon properties.

BalloonTipIcon = Info
BalloonTipText = Running
Change Icon
Text = Running Your Program
Visible = True




3. Add code in Event Form1_Resize.

Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Resize
' If minimize form that will show in system tray.
If System.Windows.Forms.FormWindowState.Minimized = WindowState Then
sysMonTray.ShowBalloonTip(5, "Running", "Running Your Program", ToolTipIcon.Info)
Me.Hide()
End If
End Sub


4. Add code in Event NotifyIcon_Click to hide and show form.

Private Sub sysMonTray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles sysMonTray.Click

If Me.Visible Then
Me.Hide()
Else
Me.Show()
Me.ShowInTaskbar = True
Me.WindowState = FormWindowState.Normal
Me.StartPosition = FormStartPosition.CenterScreen
End If

End Sub


2008-06-08

Make your programs run on Windows startup

The two best methods for automatically launching a program at startup are to use the registry or the system's Startup folder. Which method you choose depends on how easy you want to make it for the user to remove the program if he or she decides that it shouldn't run at system startup. Using the Startup folder gives the user more control; to prevent the program from running at startup, the user just has to remove its shortcut from the folder. Using the registry makes it less accessible; the user will have to be familiar with the structure of the registry and will have to know how to use an editing tool like RegEdit in order to prevent the application from running at startup.
Sample Code.

'Write to register
Dim regKey As Microsoft.Win32.RegistryKeyregKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True)
regKey.SetValue("YourApplicationName", "YourInstallPath")
regKey.Close()


If you want to remove from register use this code.

regKey.DeleteValue("YourApplicationName", False)

2008-06-03

Insert picture into Report

Insert picture into report by convert picture to byte array and add to report.


1. Add picture column in ReportDataset.xsd and set data type to System.Byte() then compile project.




2. Open CustomerReport.rpt , right click Database Fields and select Verify Database menu. Insert Picture column into report.




3. At CreateDataSet function insert this code for add new picture data column.

dt.Columns.Add("Picture", Type.GetType("System.Byte[]"))

4. Create new function.

Private Function CreatePictureArray(ByVal bImagePath As String) As Byte()
Dim imgLogo As System.Drawing.Image = System.Drawing.Image.FromFile(bImagePath)

Dim msLogo As New IO.MemoryStream()
imgLogo.Save(msLogo,
System.Drawing.Imaging.ImageFormat.Bmp)


Return msLogo.ToArray()
End Function

5. Convert image to byte array and bind to datarow.

' Create new row
Dim dr As DataRow = ds.Tables(0).NewRow

dr("Title") = "Mr"

dr("FirstName") = "Tom"
dr("LastName") = "Brown"

dr("Address") = "Tom Address"

dr("Picture") = CreatePictureArray("c:\person.jpg")

6. Show Report