Windows Phone Developers

Tuesday, May 6, 2008

.NET 3.5 Enhancements Training Kit

Overview

The .NET Framework 3.5 Enhancements Training Kit includes presentations, hands-on labs, and demos. This content is designed to help you learn how to utilize the .NET 3.5 Enhancement features including: ASP.NET MVC, ASP.NET Dynamic Data, ASP.NET AJAX History, ASP.NET Silverlight controls, ADO.NET Data Services and ADO.NET Entity Framework.

System Requirements

  • Supported Operating Systems: Windows Vista; Windows XP
Microsoft Windows Vista
Microsoft Visual Studio 2008
Microsoft SQL Server 2005 (Express recommended)
Microsoft Office Powerpoint 2007 or the PowerPoint Viewer 2007 - Required to view the presentations
Windows PowerShell 1.0 RTM

Instructions

Download and execute the kit. The kit will uncompress to the selected folder and launch a HTML browser for the content.

Download @ http://www.microsoft.com/downloads/details.aspx?FamilyID=355c80e9-fde0-4812-98b5-8a03f5874e96&displaylang=en
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Send emails asynchronously using .NET

Send Asynchronous emails using VB.NET

Imports System.Net.Mail

Imports System.Net.Mime

Imports System.ComponentModel

Sub Send_Email_Asynchronously()

Try

Dim oMailMsg As MailMessage

Dim oClient As SmtpClient

oMailMsg = New MailMessage

oMailMsg.From = New MailAddress("admin@vbadud.com")

oMailMsg.To.Add(New MailAddress("sample@yahoo.co.au"))

oClient = New SmtpClient("smtp.vbadud.com") ' configure client

AddHandler oClient.SendCompleted, AddressOf Client_SendCompleted

' Send message

oClient.EnableSsl = True

' Send Message Asynchronously

oClient.SendAsync(oMailMsg, Nothing)

Catch ex2 As SmtpFailedRecipientException

'Represents the exception that is thrown when the SmtpClient is not able to complete a Send or SendAsync operation to a particular recipient.

' Occurs when the message is delivered within the given domain

MessageBox.Show(ex2.Message)

Catch ex3 As SmtpException

' Occurs when the message is delivered within any domain

MessageBox.Show(ex3.Message)

End Try

End Sub

oClient.SendAsync sends the specified e-mail message to an SMTP server for delivery. This method does not block the calling thread and allows the caller to pass an object to the method that is invoked when the operation completes.

The following event will be raised when an asynchronous e-mail send operation completes. You can cancel the message in between too.

Private Sub Client_SendCompleted(ByVal sender As Object, ByVal e As asynccompletedeventargs)

If e.Cancelled Then '

MessageBox.Show("Message sending cancelled")

Else

If e.Error Is Nothing Then

MsgBox("Message Sent Successfully")

Else

MsgBox("error has occurred :" & e.Error.Message)

End If

End If

End Sub

Sending Asynchronous mails VB.NET, Sending Secure Mails using VB.NET, Send emails asynchronously using .NET

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Create HTML Message with Embedded Images in VB.NET / Embed images in HTML mail message using VB.NET

Send mails in both HTML and Text Format using VB.NET / Automatically direct messages in HTML / Text format using .NET

Imports System.Net.Mail

Imports System.Net.Mime

Imports System.ComponentModel

Sub Create_HTML_Mail_With_Embedded_Images()

Dim oMailMsg As MailMessage

Dim oSMtPClient As SmtpClient

Dim sTEXTBody As String

Dim avTEXTBody As AlternateView

Dim sHTMLBody As String

Dim avHTMLBody As AlternateView

oMailMsg = New MailMessage

oMailMsg.From = New MailAddress("sample@dotnetdud.com", "Dot Net Dud Sample")

' If you do not use the constructor and add address using To.Add you can add more addresses

oMailMsg.To.Add(New MailAddress("subscriber@dotnetdud.com", "Feed Subscribers"))

oMailMsg.To.Add(New MailAddress("techwriters@dotnetdud.com", "Tech Writers"))

oMailMsg.Subject = "Welcome to Mailing List"

sHTMLBody = " <> <> <> Welcome to DotNetDud Mailing List < /H1 > <> You will get mails on .... < /P > <> < src=""> < /body > < /HTML > "

sTEXTBody = "Welcome to DotNetDud Mailing List < /H1 > <> You will get mails on .... (Some images are not rendered due to text formatting)"

'Error Name 'mediatypenames' is not declared will come if Imports System.Net.Mime is not present

avHTMLBody = AlternateView.CreateAlternateViewFromString(sHTMLBody, Nothing, MediaTypeNames.Text.Html)

avTEXTBody = AlternateView.CreateAlternateViewFromString(sTEXTBody, Nothing, MediaTypeNames.Text.Plain)

' Creating Linked Resources

Dim img1 As LinkedResource = New LinkedResource("c:\temp\Img1.jpg", MediaTypeNames.Image.Jpeg)

img1.ContentId = "Img1"

avHTMLBody.LinkedResources.Add(img1)

oMailMsg.AlternateViews.Add(avHTMLBody)

oMailMsg.AlternateViews.Add(avTEXTBody)

oSMtPClient = New SmtpClient("smtp.dotnetdud.com")

oSMtPClient.Send(oMailMsg)

End Sub

LinkedResource represents an embedded external resource in an email attachment, such as an image in an HTML attachment. We use it to create a new linked resource to the image and set the MIME content ID for this attachment as Img1. The same is represented in the HTML tag as CID ( < src=""> ). The image will be rendered in appropriate position in the email

Use the AlternateViews property to specify copies of an e-mail message in different formats. For example, if you send a message in HTML, you might also want to provide a plain text version in case some of the recipients use e-mail readers that cannot display HTML content.

To add an alternate view to a MailMessage object, create an Attachment for the view, and then add it to the collection returned by AlternateViews. Use the Body property to specify the text version and use the AlternateViews collection to specify views with other MIME types. Use the MediaTypeNames class members to specify the MIME type for the alternate view.

Linked Resources in VB.NET, Alternate Views in .Net, Embed images in eMail messages using .NET, Embed Pictures in mail using .NET, HTML with embedded messages using .NET

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Send HTML Messages using .NET

Send HTML Messages using .NET

Create and Send HTML mails using VB.NET

Use the IsBodyHtml property to specify whether the body of the e-mail message contains plain text or HTML markup

Imports System.Net.Mail

Sub Create_HTML_Mail()

Dim oMailMsg As MailMessage

Dim oSMtPClient As SmtpClient

oMailMsg = New MailMessage

oMailMsg.From = New MailAddress("sample@dotnetdud.com", "Dot Net Dud Sample")

' If you do not use the constructor and add address using To.Add you can add more addresses

oMailMsg.To.Add(New MailAddress("subscriber@dotnetdud.com", "Feed Subscribers"))

oMailMsg.To.Add(New MailAddress("techwriters@dotnetdud.com", "Tech Writers"))

oMailMsg.Subject = "Welcome to Mailing List"

oMailMsg.Body = <HTML><body><H1>Welcome to DotNetDud Mailing List</H1><p>You will get mails on .... </P></body></HTML>

' IsBodyHtml differentiates from Text message and HTML Message

oMailMsg.IsBodyHtml = True

oSMtPClient = New SmtpClient("smtp.dotnetdud.com")

oSMtPClient.Send(oMailMsg)

End Sub


Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Validate eMail Addresses using VB.NET Function

Detect errors in email addresses using .NET exception handling

There are n-number of ways to detect errors in email addresses; some use regular expressions to do that. The same has been built as a check in ASP.NET validation controls.

The following function uses the Try-Catch exception handling by assigning the address to the mail message. If the format of the email address is found to be wrong, then the function returns false. A simple one; please post your comments on the way it worksJ

Function Detect_MailAddress_Errors(ByVal sMailAdd As String) As Boolean


Try

Dim oMailMsg As New MailMessage

oMailMsg.To.Add(sMailAdd)

Return True

'Format Exceptions

Catch exFormat As FormatException

'MsgBox("Format Error")

Return False

' General Exceptions

Catch ex As Exception

End Try

End Function

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Create Mail in Vb.Net with attachments

Automatically send a mail with attachment using VB.NET

Imports System.Net.Mail

Imports System.Net.Mime

Imports System.ComponentModel

Sub CreateMail_With_Attachment()

Dim oMailMsg As New MailMessage

Dim oMailClient As SmtpClient

oMailMsg.From = New MailAddress("info@vbadud.com")

oMailMsg.To.Add(New MailAddress("admin@vbadud.com", "Administrator"))

oMailMsg.Body = "Attached Sample Document for processing."

oMailMsg.Subject = "Sample Mail"

oMailMsg.Attachments.Add(New Attachment("C:\temp\sample.doc"))

oMailClient = New SmtpClient("smtp.vbadud.com")

oMailClient.Send(oMailMsg)

End Sub

The Attachment class is used with the MailMessage class. All messages include a Body, which contains the content of the message. In addition to the body, you might want to send additional files. These are sent as attachments and are represented as Attachment instances. To add an attachment to a mail message, add it to the MailMessage..::.Attachments collection.

Attachment content can be a String, Stream, or file name. You can specify the content in an attachment by using any of the Attachment constructors.

The MIME Content-Type header information for the attachment is represented by the ContentType property. The Content-Type header specifies the media type and subtype and any associated parameters. Use ContentType to get the instance associated with an attachment.

The MIME Content-Disposition header is represented by the ContentDisposition property. The Content-Disposition header specifies the presentation and file time stamps for an attachment. A Content-Disposition header is sent only if the attachment is a file. Use the ContentDisposition property to get the instance associated with an attachment.

The MIME Content-Transfer-Encoding header is represented by the TransferEncoding property.

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Creating and Sorting an ArrayList

Example of System.Collections namespace in ArrayList

The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries. Arraylist is one of the basic collection; it implements the IList interface using an array whose size is dynamically increased as required

Imports System.Collections

Sub Main()

Dim aList As New ArrayList

Dim arStr() As String = {"Apple", "Aaron", "Byron", "Reddy"}

aList.AddRange(arStr)

For Each aLis As String In aList

Console.WriteLine(aLis)

Next

Console.WriteLine()

‘Sort Array

aList.Sort()

For Each aLis As String In aList

Console.WriteLine(aLis)

Next

End Sub

This method uses Array..::.Sort, which uses the QuickSort algorithm. This implementation performs an unstable sort; that is, if two elements are equal, their order might not be preserved. In contrast, a stable sort preserves the order of elements that are equal.

On average, this method is an O(n log n) operation, where n is Count; in the worst case it is an O(n^2) operation.

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

kbAlertz.com :: Visual Studio 2005

kbAlertz.com :: Visual Studio 2008

kbAlertz.com :: Visual Basic 2005