This blog is about the dotnet.all types of codes,news about dotnet including asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.ncluding asp.net,vb.net,c# and know about new dotnet technology.programing in asp.net,vb.net,c#, ajax, AJAX tech support for .net and discuss the new technology in dotnet.asp.net programming,dot net programming,dotnet programs,dotnet source code,source code.

Free Hosting

Free Hosting

Friday, February 15, 2008

Build Your Website Fast With These Tools

Without the right tools, building a website can be very time consuming. Here you can find the software and resources that I use to make my life easier whenever I need to set up a new web site.
#1. Html Editor
The first thing you need to build a website is an html editor. In particular, you need a visual editor, that makes creating a web page as easy as creating a regular Word document.
If you have Microsoft Office on your computer, you should check whether it came with FrontPage. This is probably the best option if you have never dealt with html before. Out of all the html editors available, FrontPage is the one that most closely resembles Word.
If you don't have Frontpage and have some money to spend, I would recommend going with Macromedia Dreamweaver. This is a much more powerful visual html editor, which is slightly more difficult to use, though.
There is also a free alternative to these software. It is called Nvu and is similar to FrontPage in functionalities, but a little harder to get used to. If you have a tight budget and you are willing to invest a little more time in learning, Nvu is the way to go.
#2. Templates
Buying a ready-made website template means cutting your development time considerably. You can find professionally designed website templates that costs less than $100. If you consider how much time it would take you to create something similar, you will agree with me that it is a bargain price.
My favourite place for finding website templates is TemplateMonster.com.
#3. Graphics
If used properly, images can make a website more persuasive and convince your visitor to take the action you desire (filling up a contact form, completing a purchase, etc.). Believe me, it's not easy to find professionally looking photos and graphics at affordable prices. Whenever I need to shop for images, I know that on iStockPhoto I will find what I need.
You can buy an image for as little as one dollar and use it on as many websites as you want. Always choose "web format" when completing your purchase, the other formats are more expensive and you need them only if you plan to use that image on printed material too (you need a greater resolution for that).
#4. Image Editing Software
When you buy images on iStockPhoto, you still need to resize them to fit in your website design. You need an image editing software to do so and these are the ones I recommend.
The most widely known free image editing software is called The Gimp. It is a really complete solution, but can be intimidating for a beginner. Paint.NET is what I recommend if you have never modified an image before: it offers less features, but it's much easier to get used to.
Photoshop Elements has the best balance between ease of use and features. Adobe offers you access to Photoshop "little brother" for less than $100. I have been using this software since version 2.0 and it is getting better with every new release.
#5. Tons Of Free Scripts
Would you like to set up a contact form for your website but you don't know anything about programming? Do you want to show the current date in your web pages? Then you need to visit HotScripts.com.
This website is a collection of free and paid scripts that you can implement on your website in minutes. You can filter the results by programming language (php, asp, asp.net, javascript) and next to each script you can see whether it has a free or commercial license.
#6. Ftp Software
Now that your website is done, you need to upload it to your ftp account, so that it can be seen online. The software I recommend in this case is FileZilla. It is free and it takes you less than a minute to configure your ftp account and start uploading your files.
These are the resources that helped me save hours of work every time I needed to create a new website. I am sure they will prove their effectiveness to you too!







ASP.NET Web Hosting

ASP means Active Server Pages and it is a server-side technology built by Microsoft to allow website owners to build dynamic web pages. An ASP.NET web site hosting service is a server that supports applications build in ASP.
What Can ASP.NET web hosting Do For You?
An ASP.NET web hosting service allows you to create dynamic web pages. If you are the owner of an online business, you can use ASP.NET to create order forms for your customers to fill in. Another way to use ASP.NET is to create a contact form or make a survey on your site. It also offers you the possibility you to display time, date and other types of information in various ways.
How To Choose an ASP.NET web hosting Service?
The first thing you have to do is take a look at the files you need to host and determine how much storage space you need. The average price for 1GB storage space is less than $10 a month and you have to make sure you don't overpay. Try not to spare your disk space, no matter how much you have. Keep all your ASP.NET and HTML files optimized and compress your images. The smaller they are, the faster will your web pages load.
Another important thing in choosing an ASP.NET web hosting service is bandwidth. If you have included only a few pictures on your website and your files are small, you don't need too much bandwidth. However, if you have larger files, such as big images, MPEG or MP3 files, bandwidth is very important for your pages to load fast.

While some ASP.NET web hosting services provide only basic database options, such as MySQL or Access, others offer MSSQL as well. If you own a small business, Access or MySQL should be enough. However, if you can predict you will have to handle high traffic, an ASP.NET web hosting service is better.

Connectivity is yet another important issue when choosing an ASP.NET web hosting service. Ask your potential provider about the Internet connection they have and the number of ISPs they are connected to for preventing downtime. Ask what their uptime guarantee is and look over customer reviews to see if their clients are satisfied.

Don't be tempted to stop at a very cheap ASP.NET web hosting package. Check if you are dealing with a reliable provider, preferably one that has been in business for several years. Find out about the type of technical support they are offering. You should be able to learn about this from their website. Find out if they have a 24/7 service and a hotline as well.

Top ASP.NET web hosting Providers
Discount ASP.NET
This is a world leader in ASP.NET web hosting, with three awards from prestigious hosting publications in only one year. You can choose from several ASP.NET packages with advanced features all at affordable prices.
Maximum ASP
Maximum ASP is another reliable ASP.NET web hosting provider, offering a wide range of hosting packages and the most advanced Microsoft technologies.
Seek Dot Net
Seek Dot Net is another worldwide recognized hosting provider, with offices in United States and Australia. They offer a wide range of hosting solutions, such as shared, dedicated and enterprise packages, and provide a high level of technical support. With just a little information on what you need to look for in an ASP.NET host, you will sure find the right provider that will help you develop a strong online business.

Thursday, February 14, 2008

Saving sent email Information to XML c#

This is a sample c# AddIn, hooking the SentFolder Items Add Event, and saves Information from outgoing Emails to an XML file. (Saving sent email Information to XML c# )
CODE:
namespace TestAddIn
{
using System;
using Off = Microsoft.Office.Core;
using Ol = Microsoft.Office.Interop.Outlook ;
using Extensibility; using System.Runtime.InteropServices;
using System.Data;
using System.Xml;
using System.IO;
using System.Reflection;
using System.Diagnostics ;
#region Read me for Add-in installation and setup information.

// When run, the Add-in wizard prepared the registry for the Add-in.
// At a later time, if the Add-in becomes unavailable for reasons such as:
// 1) You moved this project to a computer other than which is was originally created on.
// 2) You chose 'Yes' when presented with a message asking if you wish to remove the Add-in.
// 3) Registry corruption.
// you will need to re-register the Add-in by building the MyAddin21Setup project
// by right clicking the project in the Solution Explorer, then choosing install. #endregion
///


/// The object for implementing an Add-in.
///

///
[GuidAttribute("CFC4FD8C-6769-46C2-8B32-F3ACA3A14CF1"),
ProgId("TestAddIn.Connect")]
public class Connect : Object,
Extensibility.IDTExtensibility2
{
// The Instance Object private object myInstance;

// The Application Object private Ol.Application myApplication;
// The Sent Folder private Ol.MAPIFolder mySentFolder;

// My DataSet private DataSet myDataSet;
// My DataTable private DataTable myDataTable;
///
/// Implements the constructor for the Add-in object.
/// Place your initialization code within this method.
///
public Connect()

{
}
///
/// Implements the OnConnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being loaded.
///

///
/// Root object of the host application.
///
///
/// Describes how the Add-in is being loaded.
///
///
/// Object representing this Add-in.
///
///
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode,
object addInInst, ref System.Array custom)
{
try
{ myApplication = (Ol.Application) application;
myInstance = addInInst;
LoadXMLData();

mySentFolder = myApplication.Session.GetDefaultFolder (Ol.OlDefaultFolders.olFolderSentMail );
mySentFolder.Items.ItemAdd +=new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
}
catch (System.Exception ex)
{
Debug.WriteLine(ex);
}
}
///
/// Implements the OnDisconnection method of the IDTExtensibility2 interface.
/// Receives notification that the Add-in is being unloaded.
///

///
/// Describes how the Add-in is being unloaded.
///
///
/// Array of parameters that are host application specific.
///
///
public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
{
myInstance = null;
if (mySentFolder != null)
{
// DeRegister Event mySentFolder.Items.ItemAdd -=new Microsoft.Office.Interop.Outlook.ItemsEvents_ItemAddEventHandler(Items_ItemAdd);
Marshal.ReleaseComObject(myApplication);
}
if (myApplication != null)
{
Marshal.ReleaseComObject(myApplication);
}
GC.Collect ();
}
///
/// Implements the OnAddInsUpdate method of the IDTExtensibility2 interface.
/// Receives notification that the collection of Add-ins has changed.
///

///
/// Array of parameters that are host application specific.
///
///
public void OnAddInsUpdate(ref System.Array custom)
{
}
///
/// Implements the OnStartupComplete method of the IDTExtensibility2 interface.
/// Receives notification that the host application has completed loading.
///

///
/// Array of parameters that are host application specific.
///
///
public void OnStartupComplete(ref System.Array custom)
{
}
///
/// Implements the OnBeginShutdown method of the IDTExtensibility2 interface.
/// Receives notification that the host application is being unloaded.
///
///

/// Array of parameters that are host application specific.
///
///
public void OnBeginShutdown(ref System.Array custom)
{
}
///
/// Loads the Data from XML File
///

private void LoadXMLData()
{
// Create a new DataSet myDataSet = new DataSet ("SentData");
// Check, if File exists if (File.Exists (@"C:\mydata.xml"))
{
// Yes, read the XML-Data into Dataset myDataSet.ReadXml (@"C:\mydata.xml");
// Get the DataTable
if (myDataSet.Tables.Count > 0)

{
myDataTable = myDataSet.Tables [0];
}
}
if (myDataTable == null)

{
// Create a new DataTable myDataTable = new DataTable("DataTable");

// Add Columns to DataTable (would be nicer with a SchemaFile) myDataTable.Columns.Add ("EntryID",Type.GetType ("System.String")); myDataTable.Columns.Add ("Subject",Type.GetType("System.String")); myDataTable.Columns.Add ("SentOn",Type.GetType("System.DateTime"));
myDataSet.Tables.Add (myDataTable);
SaveXMLData();
}
}
///
/// Saves the Data to XML
///

private void SaveXMLData()
{
// Accept Changes myDataSet.AcceptChanges ();
// Save the XML Data myDataSet.WriteXml (@"C:\mydata.xml");
}
///
/// EventHandler for Items Add Event of Sent Folder
///

/// The Outlook Item
private void Items_ItemAdd(object Item)
{
Ol.MailItem myMail = null; try
{
// Check Item, could be a MeetingRequest also if (Item is Ol.MailItem)
{
// Cast Object to MailItem myMail = (Ol.MailItem) Item;
// Create a new DataRow DataRow newRow = myDataTable.NewRow ();
// Fill Data into Row newRow["EntryID"] = myMail.EntryID; newRow["Subject"] = myMail.Subject ; newRow["SentOn"] = myMail.SentOn ;
// Add Row to DataTable myDataTable.Rows.Add (newRow);

myDataTable.AcceptChanges ();
// Save new Data SaveXMLData();
}
}
catch (System.Exception ex)
{
Debug.WriteLine(ex.Message );
}
finally
{ // Release the Reference to MailObject if (myMail != null) { Marshal.ReleaseComObject (myMail);
}
}
}
}
}

Friday, February 8, 2008

.NET Languages

The common language runtime defines a common runtime for all .NET languages. Although C# and VB.NET are the two flagship languages of .NET, any language that targets the common language runtime is on equal footing with any other language. In this section we'll talk about the features that the .NET languages offer.

Classes and Objects:
The common language runtime deals in managed types. The runtime can load types, execute methods of a type, and instantiate objects of a type. Although the common language runtime supports several forms of types, such as classes, interfaces, structures, enumerations, and delegates, all of these forms ultimately are represented as classes at the lowest levels of the runtime. And although the common language runtime does support exporting entry points that are not enclosed in a type, at least two languages (VB.NET and C#) do not support entry points outside of a type definition.

Although in OOP it is possible to invoke some class methods without objects, the most common use of classes is to produce objects. In the common language runtime, an object is an instance of exactly one class. The operations that may be performed on an object are determined by the object's class. The amount and type of storage used by the object is determined by the object's class. In essence, the class acts as a factory or template for objects that belong to that class.

The common language runtime supports instantiating objects based on a class. Each programming language exposes this functionality somewhat differently. In C# and VB.NET, for example, the new keyword is used to create a new object of a given class, as shown in the following two code snippets:

C#
IceCream ic = new IceCream();
ic.MakeACone();

VB

Dim ic as new IceCream();
ic.MakeACone ()

Classes are defined in C# and in VB.NET using the class keyword. The following code shows sample classes in each:

C# Class

public class IceCream
{
string strFlavor = "Chocolate";
public void MakeACone()
{
System.Console.Write( "I have made a cone. My flavor is "
);
System.Console.WriteLine( strFlavor + "." );
}
}

VB.NET Class

Public Class IceCream
Dim strFlavor as string = "Chocolate"
Public Sub MakeACone()
System.Console.Write("I have made a cone. My flavor is ")
System.Console.WriteLine(strFlavor & ".")
End Sub
End Class

Constructors

Unless the programmer takes special steps, the fields of the class will be set to a well-known initial value when an object is created. Numeric types are set to zero, and objects are set to null (C#) or Nothing (VB). You can change the values that are used by writing a constructor. A constructor is a special method that is called automatically to set the class's fields to a programmer-determined state prior to the first use of the object (or class).

Constructors are called when a new object is created, before the new operator returns the reference to the new object. Constructors may accept parameters, and they may be overloaded based on parameter count or type. The following code shows typical constructors:

C#

public class IceCream
{
private int i = 5;
public IceCream()
{
System.Console.WriteLine( "This is delicious!" );
}
}


VB.NET

Public Class IceCream
Sub New()
System.Console.WriteLine( "This is delicious!" )
End Sub
End Class

Namespaces
Namespaces
in the .NET runtime are used to organize classes and types into separate spaces. You define namespaces using the namespace keyword, as shown in the following code:

namespace Rick
{
public class MyClass
{
public static void DoSomething()
{
}
}
}

The using keyword in C# promotes elements in other namespaces into the global namespace. The following code shows an example of referencing two separate namespaces with the using keyword:

using Rick;
using System;


MyClass.DoSomething();
Console.WriteLine( "Just called DoSomething()" );



Installing SQL Server 2005 Express Edition

After making sure IIS, the .NET Framework, and the SDK are installed correctly,
it’s time to move forward and install the next piece of software that you’ll be
using as we work through this book: SQL Server 2005 Express Edition.

SQL Server 2005 is Microsoft’s database solution for medium to large companies
and enterprises. SQL Server 2005 can be quite expensive, it generally requires
its own dedicated database server machine, and, at times, it necessitates that a
certified database administrator (DBA) be employed to ensure its maintenance;
yet it does offer a robust and scalable solution for larger web applications.

For the examples in this book, we’ll use SQL Server 2005 Express Edition, which
is free and sufficiently powerful for our needs. Unlike the expensive versions,
SQL Server 2005 Express Edition doesn’t ship with visual management utilities,
but you can use another free tool from Microsoft—SQL Server Management
Studio Express, which we’ll install next)—for these purposes.

You can install SQL Server 2005 Express Edition as follows:

1. Navigate to http://msdn.microsoft.com/vstudio/express/sql/, and click the
Download Now link.

2. In the next page, you can choose between SQL Server 2005 Express Edition,
and SQL Server 2005 Express Edition with Advanced Services. The former
will be fine for our purposes. Your system should meet the necessary requirements,
so go ahead and click Download.

3. Once the download has completed, double-click the downloaded executable
file, and follow the steps to install the product. It’s safe to use the default
options all the way through, though it is a rather long process.

Provided that everything goes well, SQL Server 2005 Express Edition will be up
and running at the end of the process. Like IIS, SQL Server runs as a service in
the background, accepting connections to databases instead of web pages. The
SQL Server is accessible at the address (local)\SqlExpress.

Installing the .NET Framework

Installing the .NET Framework:
The best method of acquiring the .NET Framework is to download and install it directly from the Web. Note that it is also delivered through Windows Update, so you may already have it installed on your system. To check, open the folder C:\WINDOWS\Microsoft.NET\Framework (if your copy of Windows is installed somewhere other than C:\WINDOWS, change this path accordingly). If this folder doesn’t exist, you definitely don’t have the .NET Framework installed. If it does exist, you should find inside it at least one folder with a name like v1.1.4322. Each of these kinds of folders holds a different version of the .NET Framework you have installed. If at least one of these folders’ names doesn’t start with v2 or higher, you’ll need to install the latest version of the .NET Framework.

To install the latest version of the .NET Framework, simply follow the steps
outlined below:


1. Go to the ASP.NET support site5 and click the Download the .NET Framework
link.


2. Under the .NET Framework Version 2.0 Redistributable Package heading, click the appropriate download link for your hardware. Remember, we’ll install the redistributable package first, then the SDK. The link will advance you to a download page.

3. Choose the language and version of the installation you want, and click Download.

4. Save the file to a local directory. After the download is complete, doubleclick the executable to begin the installation.

5. Follow the steps presented by the wizard until installation completes.

Thursday, February 7, 2008

What Is ASP.NET?

The original definition of ASP.NET, right at the start of the chapter, portrayed ASP.NET as a powerful and flexible technology for creating dynamic Web pages, and this still holds true. However, as you now know, it isn't the only way to deliver dynamic Web pages, so let's refine our definition a little so it reads as follows:

ASP.NET is a powerful and flexible server-side technology for creating dynamic Web pages.


Secondly, ASP.NET is only one of a set of technologies that comprise the .NET Framework. For now, you can think of this as a giant toolkit for creating all sorts of applications, and in particular, for creating applications on the Web. When you install ASP.NET, you will also install the .NET Framework at the same time. You will use bits and pieces of the .NET Framework throughout this book. In fact, you can also use the old versions of ASP with the .NET Framework, so why are we not using that instead?

How Does ASP.NET Differ from ASP?

ASP is restricted to using scripting languages, mainly JavaScript or VBScript (although it can be any scripting language supported by the Windows system). Scripting languages are like cut-down or junior versions of full programming languages in that they aren't as powerful and don't support all the features of full programming languages. In addition, when you add ASP code to your pages, you do it in the same way as you would do client-side script, and this leads to problems such as messy coding and restricted functionality.

ASP.NET has no such problems. It allows you to use a far greater selection of full programming
languages and fully utilize the rich potential of the .NET Framework. It helps you create faster, more reliable, dynamic Web pages with any of the programming languages supported by the .NET Framework. Typical languages supported natively are C#, VB .NET and JScript.NET (a new version of Jscript). On top of this, it is expected that third party developers will create versions of Perl, Python, and many others to work in ASP.NET.


Secondly, ASP.NET comes with a far greater set of controls that you can place on a page without any extra ASP.NET coding. With classic ASP, programmers tended to rely on six objects, such as Request and Response to do everything and a couple of extra components that came with ASP. With ASP.NET, things are more jargon free. If you want to put a button on your page, you put an ASP.NET Button control on your page, and if you want a text box, you place an ASP.NET TextBox control. ASP.NET comes with a rich set of controls that can be applied to many common development scenarios.

A third and final reason is the separation of your ASP.NET code from your HTML. It's a commonly cited reason, if not always a well-explained one. Designers and developers play two very different roles in Web development. For instance, a developer could program a lottery number generator, but probably couldn't design a logo for a company. It makes sense to keep these two disciplines separate.

However, in ASP they aren't separate. The ASP code is sprinkled liberally between the HTML lines, like nuts over an ice cream sundae. That might be fine, unless you happen to be allergic to nuts. Now stretching this allegory a bit, it's quite common for designers to need to tinker with the actual HTML code on a Web site, but how can they alter it with confidence, if it's totally interspersed with the ASP code? In ASP.NET, you can keep the ASP code and HTML in separate files, making both the developer and the designer's life much simpler.


Using C# with ASP.NET

ASP.NET has been described as a technology and not a language, and this is an important distinction! ASP.NET pages can be made from one of many languages. However, you are not expected to know many different languages, nor are we going to teach them to you. This book uses just one language, C#, to demonstrate ASP.NET. We've chosen C# as it's arguably the most concise, and it can do just about anything that the other .NET languages can. Lastly and most importantly, C# comes free with ASP.NET – so when you install ASP.NET you get C# as well!

At this stage you may be thinking, "Hang on, I've got to figure out C#, then I've got to get a handle on ASP.NET – that sounds like an awful lot to learn." Don't worry; you won't be learning two languages. ASP.NET, as we said right from the beginning, is not a language – it is a technology. This technology is accessible via a programming language. What we're going to be doing is teaching you ASP.NET features as we teach you C#. In other words, you will be creating your Web pages using C# and using ASP.NET to drive it. However, before you rush out and get a C# book instead, remember that this book will approach the language from the angle of creating dynamic Web pages only.

ASP.NET is a server-side technology that lets you use fully fledged programming
languages to create your Web pages.


Tuesday, February 5, 2008

Redirecting Outlook Reminders

Today's article will guide you through creating an add-in to Outlook 2003 to send alerts to another computer when a reminder is raised.

I worked with the new Visual Studio 2005 Tools for Microsoft Office (VSTO 2005) newly released support for Microsoft Outlook (currently beta). At that point, it was enough to just get it installed, set up the snippets, and take a look at the samples. I created a starter project to demonstrate creating a new mail item and task. Of course it was just a stepping stone to the great things you can do with the beta, but I wanted to do something useful this time.
I don't know about you, but in my house I have my laptop that floats from room to room, a main desktop in the office, a media center computer, my wife's computer, and other assorted boxes awaiting upgrades or repair. I have Outlook installed on my laptop to keep it portable. Obviously, with all of the aforementioned systems, I'm not always sitting in front of my laptop. This means that meeting and task reminders will often go off without me noticing them. Not a good situation!


As they say, necessity is the mother of invention. "Wouldn't it be nice if I could be alerted on a different computer since Outlook is bound to only one?" I thought. Then, it came to me. The new VSTO 2005 for Outlook support was the answer! Why not register for event notifications when a reminder goes off, and raise an alert somewhere else? And from that, Outlook Alerts was born.
Today's article will guide you through creating an add-in to Outlook 2003 to send alerts to another computer when a reminder is raised. In order to follow this article and run the code, you will need any of the Visual Studio Express editions. The code samples in this article are shown in Visual Basic 2005; however, the downloadable source code is available in both VB 2005 and C# 2005. Beta 2 of the Express editions can be downloaded from http://msdn.microsoft.com/express. As with last time, Microsoft Office 2003 (Service Pack 1) is also a requirement, or at least Outlook 2003 SP1. Be aware that Outlook Express will not function as a replacement for Outlook.

The first step in sending alerts remotely is to detect when reminders and alarms are triggered in Outlook. As it turns out, this is easy to hook into, as the main Application object exposes a Reminder event. By registering an event handler for this, you are notified every time the Outlook Reminder dialog appears. The item parameter contains a reference to the item causing the event. This could be a mail item, an appointment, or any other Outlook item supporting reminders. The following method declaration creates a method which will be triggered whenever the Reminder event is raised:

Visual C#
void ThisApplication_Reminder(object item)

Visual Basic
Private Sub ThisApplication_Reminder(ByVal item As Object) Handles

The alerts application has two settings to keep track of. Settings can seem like a challenge. You may not be sure where to store them or what format to use, and writing the code to serialize them and deserialize them can be tedious. Fortunately, the .NET 2.0 framework makes this trivial. Simply right-click the project in the Solution Explorer, then click Properties. Choose the Settings tab and you can create and manage any settings you need. You have the ability to create user or application scope settings with arbitrary names, in a variety of data types. For this project, create a Boolean setting called RemoteRemindersEnabled, and a String setting called RemoteReminderAddress. The first flag controls whether or not alerts will be sent remotely, while the second flag specifies where to send any alerts. The address should be an IP address or net name. Note that unless the other computer is in the same workgroup or domain, it is generally easier to use IP address to guarantee delivery. The Settingsconfiguration should look like this:

(click image to zoom)
Once the settings are created, you can access them in a strongly-typed fashion using the My namespace in Visual Basic as follows:

Visual C#
Properties.Settings.Default.RemoteRemindersEnabled

Visual Basic
My.Settings.RemoteRemindersEnabled

If you use settings, you must provide an easy way to allow users to manage the setting values. Outlook allows you to add menus alongside the built-in menus. This is easy to do and provides a professional look to your add-in. The first step is to obtain a reference to the main menu bar and add a top-level menu; in this case, "Add-in Tasks." The code looks a little messy due to type casting (the CType call) and the two Type.Missing parameters. These are necessary due to the underlying COM nature of the code:

Visual C#
_menuBar = this.ActiveExplorer().CommandBars.ActiveMenuBar;
_helpMenuIndex = _menuBar.Controls[MENU_BEFORE].Index;
_topMenu = (Office.CommandBarPopup)(_menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing, _helpMenuIndex, true));
_topMenu.Caption = "Add-in Tasks";
_topMenu.Visible = true;

Visual Basic
_menuBar = Me.ActiveExplorer().CommandBars.ActiveMenuBar_helpMenuIndex = _menuBar.Controls(MENU_BEFORE).Index_topMenu = CType(_menuBar.Controls.Add(Office.MsoControlType.msoControlPopup, Type.Missing, Type.Missing,
_helpMenuIndex, True), Office.CommandBarPopup)
_topMenu.Caption = "Add-in Tasks" _topMenu.Visible = True

After creating the menu, you add menu items by calling the Controls.Add() method. Once again, the code looks a little cluttered, but is overall very understandable. The Caption properties in both cases determine what is seen when the menu is opened:

Visual C#
_settingsMenu = (Office.CommandBarButton)(_topMenu.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, true));
_settingsMenu.Caption = "Remote Alert Notification Settings...";
_settingsMenu.Visible = true;
_settingsMenu.Enabled = true;

Visual Basic
_settingsMenu = CType(_topMenu.Controls.Add(Office.MsoControlType.msoControlButton, Type.Missing, Type.Missing, Type.Missing, True), Office.CommandBarButton)_settingsMenu.Caption = "Remote Alert Notification Settings..."
_settingsMenu.Visible = True
_settingsMenu.Enabled = True

You will still need to create a settings form, and create an event handler to respond to user clicks on the item. At runtime, selecting the Add-in Tasks Remote Alert Notification Settings menu option brings up this custom dialog:





C# Catchall Onarrival Event sink

One of the Event sinks that comes in handy from time to time especially if people own a lot of domains is the catch all event sink from http://support.microsoft.com/?kbid=324021 .Now the .NET frameworks a bit more prevalent and the fact I wanted to use this on my Internal servers for something I thought I’d give converting this sink to C# ago. There are two ways you can go about writing SMTP event sinks in managed code the first is to build some wrappers as outlined in on msdn. This gives you access to all the protocol and transport events. The second way to build a SMTP event sink in managed code is to use the CDO onarrival event whose interfaces are defined in the cdoex.dll file (or cdosys.dll if you don’t have Exchange). The downside of using the CDO interface is that it adds significant overhead and is synchronous but the upside is that it that it handles most of the parsing and MIME issues. There’s a good doc here that discusses the issues . But using C# is a step up from VBS and should avoid all those nasty STA issues discussed here.

For the code itself its mostly based on the code from the KB with one major exception. I’ve added a section that checks and sets an X-header on the message if it’s processed by the sink. I did this to make sure the sink wouldn’t run multiple times on a message which was in response to an issue that I had with this sink (as well as the original script) in my environment. What happened for me was that I was a little lazy when I registered the sink and instead of just registering it to run on messages being sent to my catch all domain I registered it to run on all messages that where being processed by the server. This was fine for all normal message traffic that flowed though the server but a problem arose when I had some messages that where bound for a mail enabled public folders. I have a front-backend setup and I have a public store mounted on my front end server which contains the folder hierarchy. So when my front end server received the message bound from a mail-enabled public folder it would deliver it locally first as per its logic and then it would resubmit it once it work out where a replica for that folder existed ref . When the event sink ran on this resubmitted message even though it wasn’t making any changes to it the code still goes though the process of writing the recipient list back to the envelope field and calls datasource.save to update the message. Something was happening within this process which would then cause a message loop on my front-backend servers which would just continually bounce the message between each of the servers until I removed the sink. This may mean I have a problem somewhere else and it wouldn’t have happened if I had bound the sink correctly in the first place but it was enough to prompt me to change this sink to prevent this type of thing happening In the future. The one draw back of adding an X-header was that it invalidates any digital signatures but for a catch domain this isn’t a big deal.

Down to the coding

The first thing to do is create a new classlibrary project in visual studio

To create the sink you need to grab 3 dll’s from your server the first is the codex.dll you also should grab the seo.dll from %windir%\system32\inetsrv and the last dll you need is the PIA for ado. I used the PIA from OWA on Exchange 2003 which is the Adodb.dll file in the Exchsrvr\OMA\browse\bin directory. This is one thing you need to be careful of as there are a few PIA’s kicking around which are different versions. Before you use it you may want to list to see if any are registered in the GAC by using gacutil –l. Usually there isn’t but I had a problem on one server where I had a version of ADODB registered in the GAC which was a different version then the PIA I was trying to use which caused a much of problems.

Once you have all the DLL’s you need to create strong named assemblies for codex and seo so you need to first create a keypair with sn.exe eg sn.exe –k :SMTPOnarrival.key

Then using Tlbimp.exe build some Interop dll’s I’ve used the namespace switch to make sure CDOEX gets assigned CDO for the namespace eg

tlbimp
cdoex.dll /namespace:CDO /keyfile:SMTPOnarrival.key /out:Interop.cdoex.dll

tlbimp
seo.dll /namespace:SEO /keyfile:SMTPOnarrival.key /out:Interop.seo.dll

Once you’ve done this you can then reference all three dll’s in your project and you also need to add the keypair name to AssemblyKeyFile property in the assembly info.

The other thing you need to do is in the project properties-configuration properties you need to make sure that Regsiter for Com interop is set to true

Add the code then make sure you add a new unique GUID using Tools – Create GUID (create registry format). You need to change the catch domain and replace mailbox in the code which are hard coded as well you should set a unique x-header for the server.

Once you’ve done this you need to register your dll using regasm with the /codebase switch eg regasm onarrivalesink.dll /codebase

And then finally bind your sink using SMTPreg.vbs (which comes with the Exchange SDK there is also a copy in http://support.microsoft.com/?kbid=324021). When your binding it I would make sure you bind it so it only fires on emails sent to your catch domain recipients so a registration like

cscript smtpreg.vbs /add 1 onarrival CatchallSink SMTPonarrival.Catchall "rcpt to=*@youdomain.com"

If you want to debug your code (which you should only be doing on a dev server) because SMTP event sinks run in-process (of IIS) within Visual Studio to debug you need to select tools – debug process and then attach to the inetinfo.exe process (for CLR). The only quirk that I found was that Inetinfo needs to have successfully loaded your code to allow you to connect the debugger (eg the sink needs to have fired once first) or you just can’t connect. The other small quirk that I haven’t worked out yet is that I had to keep restarting the IISadmin service (and dependants) to make it release the DLL so I could make changes.

The code I’ve used is very low on testing so I wouldn’t trust it in anything other then a test environment.

I’ve put a downloadable copy of the code here

The code itself looks like
using System;
using System.Runtime.InteropServices;
using CDO;
using ADODB;
using SEO;

namespace SMTPonarrival
{
[Guid("E045FD54-4E2D-4a8e-8431-FF351F98B14A")]
public class Catchall : ISMTPOnArrival , IEventIsCacheable
{
void ISMTPOnArrival.OnArrival(IMessage msg, ref CdoEv
entStatus EventStatus)
{
try
{
if (msg.Fields["urn:schemas:mailheader:X-catchall"].Value == null)
{
ProcessMessage(msg);
};
}
catch(Exception e)
{
System.IO.StreamWriter logfile = new System.IO.StreamWriter("c:\\SMTPEventerrorlog.txt",true);logfile.WriteLine("Sink Fired : " + System.DateTime.Now);
logfile.WriteLine("Error : " + e.Message);
logfile.Close();
}
}
//Set Event Status to CDO_RUN_NEXT_SINKEventStatus = CDO.CdoEventStatus.cdoRunNextSink;
}
void IEventIsCacheable.IsCacheable()
{
// This will return S_OK by default.
}
private void ProcessMessage(IMessage msg1)
{
string RECIPLIST;RECIPLIST = http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist;
string strFixedListlc;
string searchdomain = "@catchdomain.com";
string strreplaceaddr = "SMTP:catchmailbox@yourdomain.com;";
string strFixedList = msg1.EnvelopeFields[RECIPLIST].Value.ToString();
while (strFixedList.IndexOf(searchdomain ,1) != -1 )
{
strFixedListlc = strFixedList.ToLower();
int nDomainPart = strFixedListlc.IndexOf(searchdomain,1);
int nNamePart = strFixedList.LastIndexOf(";",nDomainPart);int nNextAddress = strFixedList.IndexOf("SMTP:",nDomainPart);i
f (nNamePart == -1)
{
if (nNextAddress == -1)
{
strFixedList = strreplaceaddr;
}
else
{
strFixedList = strreplaceaddr + strFixedList.Remove(0,nNextAddress);
}
}
else
{
if (nNextAddress == -1)
{
strFixedList = strFixedList.Remove(nNamePart,strFixedList.Length-nNamePart) + ";" + strreplaceaddr;
}
else
{
strFixedList = strFixedList.Remove(nNamePart,strFixedList.Length-nNamePart) + ";" + strreplaceaddr + strFixedList.Remove(0,nNextAddress);
}
}
}
msg1.EnvelopeFields[RECIPLIST].Value = strFixedList;msg1.EnvelopeFields.Update();
msg1.Fields["urn:schemas:mailheader:X-catchall"].Value = "Server-CatchALL";
msg1.Fields.Update();
msg1.DataSource.Save();
}
}
}

Sending Mail with ASP.NET 2.0

sending mail with ASP.NET 2.0. In ASP.NET 2.0, Microsoft deprecated the System.Web.Mail namespace and replaced it with System.Net.Mail. The new library introduces some new features, but it also includes some bugs in how mail is sent. Before discussing some of these in detail, let's go through some code sample (which assumes you've added a using System.Net.Mail at the top of the file):
CODE
MailMessage msg = new MailMessage();
msg.From = new MailAddress("address@domain.com", "Person's Name");
msg.To.Add(new MailAddress("destination@domain.com", "Addressee's Name");
msg.To.Add(new MailAddress("destination2@domain.com", "Addressee 2's Name");
msg.Subject = "Message Subject";
msg.Body = "Mail body content";
msg.IsBodyHtml = true;
msg.Priority = MailPriority.High;
SmtpClient c = new SmtpClient("mailserver.domain.com");
c.Send(msg);
Hey it was really simple in asp.net as compared to any other languages ...

Friday, February 1, 2008

How to print the content of a Listview control using Visual Basic .NET

The Listview control can be used as a simple grid control to output tabular data, reports structured in columns and data formatted in the "familiar" spread-sheet mode. As most .NET programmers will have found, all you have to do is set the View property to "Details" and you have a simple grid control. If you are new to this and want to see how to layout such a ListView grid and how to populate it with data you can download a demonstration project from here.

In many instances, populated grids are long enough or contain data of sufficient complexity to make it worth offering our users a print option. The .NET Frameworks provide a base class ( PrintDocument) ready and waiting to provide Page Set-Up, Print Preview and Printing functionality. That's the good news, the bad news is that you have to write the code that actually manages the printing of the grid content in discrete pages. But more good news - you can download the source code of a class from here that will manage all that for you. All you have to do is point your print menu options or buttons at the relevant methods exposed by this class.

At it's simplest, all you have to do is create an instance of the class (passing it the ListView control it is going to work with) and then call one of the three public methods when required. This class is capable, however, of further development but already provides some additional (optional) features that you might want to use but these involve nothing more than setting some properties.

So what can the ListViewPrint class do?
It's primary function is to print the content of a ListView formatted as a simple grid control. It will manage ListView grids that extend to multiple pages in both the vertical and horizontal dimensions - printing the pages to the user's choice of printer or in the print preview mode.

The ListViewPrint class can also append a title to the first (or all pages) with full control over the title font if required.

The ListViewPrint class can repeat column headings above each column on all pages - ensuring that the end user always understands the content of each page.

The ListViewPrint class can be set to "compress" the output to fit a single page width - with the vertical dimension being compressed proportionately. This is not wildly sophisticated but very effective for reports that are just a little too wide to fit the width of a single sheet of standard A4 or Letter (depending upon your local).

Adding ListView printing to your Visual Basic .NET application
The simplest method (and the one that lets you follow the code during execution) is to copy the ListviewPrint class code file (ListViewPrint.vb) into your project folder. Then use the Project/Add Existing Item menu to locate and add the ListViewPrint class to your project. Alternately you could copy and paste the code from the ListViewPrint class into a class that you created directly within your project.

Next, you need to declare an instance of the ListViewPrint class in your code using the WithEvents keyword. Plus you will need to initialise that instance and pass it the identity of the ListView it will be responsible for printing.

Friend WithEvents ListViewPrint1 As ListViewPrint
ListViewPrint1 = New ListViewPrint(ListViewGrid)

Most users are used to locating print functions using the file menu. So drop an instance of the MainMenu control onto your form and reate a File menu with sub-entries for Page Setup, Print Preview and Print.

In the Click event for Page set-up you just need to call the related method in the ListViewPrint class - something like:

Private Sub mnuFilePageSetup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePageSetup.Click
ListViewPrint1.PageSetUp()
End Sub

With similar links for the Print Preview and Print menu item clicks as well

Private Sub mnuFilePrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePrintPreview.Click
ListViewPrint1.PrintPreview()
End Sub

Private Sub mnuFilePrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFilePrint.Click
ListViewPrint1.PrintGrid()
End Sub

That is all the code you need to get started with printing ListView control contents. However there are some optional properties that you might like to set.

GridFont - I would advise setting this value to equal the current Font being used by the ListView although a sensible default will be substituted if you skip setting this property.

ReportTitle - setting this string property will result in the string being output as a title on the first printed page.

TitleFont - This property can be used to set the required font for the title when it is printed.

RepeatTitle - setting this boolean attribute to True will result in the title string being repeated at the top of every page.

RepeatColumnHeadings - this boolean attribute will result in the re-printing of the grid column headings on every printed page as well as on the first.

PrintGridLines - this boolean attribute (set by default to True) can be used to print or suppress the printing of the grid cell boarders.

CompressToPage - this boolean property can be set to compress the width of the printed output sufficiently to fit the width of the current page. The vertical size of the grid is compressed in proportion but may require more than one page in height.

Downloading the ListView printing class

Click here to download the source code for the ListView Print class

Remember, you can also download the Visual Basic ,.NET source for a project demonstrating the use of the ListView Print class and companion DataGrid Print class.

The future of the ListViewPrint class
The ListViewPrint class will continue to be developed alongside the companion DataGridPrint class (for printing DataGrid control contents). For future updates and added functionality please revisit this page from time to time. We will post the version number and revision date near the top of the page.

Please let us know if you add some interesting additional functionality as we will be happy to review and publish contributions.

Can the ListViewPrint class be used in a C# project?
Yes it can. The simplest was is to compile the class into a DLL and then add a reference to that DLL to your project. You would need to distribute the DLL alongside your executable but the full functionality of the class would be available to you. Alternately, you could use one of the facilities available on the Internet to convert the code to C#.

what is Vcalendar

VCalendar (Virtual Calendar) is an open source Web calendar application with related tools, for posting and maintaining events and schedules online, in calendar format. This is an excellent and free solution for use by online Web communities and any commercial and non-commercial organizations. Unlike any other online calendars, VCalendar comes with source code in multiple programming languages: PHP, ASP and ASP.NET (C# and VB.NET); with potential for adding more technologies in the future.

vCalendar is an industry standard format for exchanging scheduling and activity-recording information electronically. If someone sends you their week's schedule in a vCalendar attachment to an e-mail note, you can drag-and drop it (or otherwise move it) to a personal information manager (PIM) type of application program and integrate with or relate it to your own schedule. vCalendar was developed along with the vCard electronic business card specification.

Like vCard, vCalendar was developed by a consortium founded by Apple, AT&T, IBM, and Siemens. The specification was turned over to an industry group, the Internet Mail Consortium (IMC), in 1996. Like vCard, vCalendar requires that you have an application program that supports its use. In time, it's expected that most personal information manager programs on all computer software platforms will support vCard and vCalendar as a standard exchange format.

Key Features:
Some of the advanced features of VCalendar include:
1. Localization features, with initial Internationalization in English and Russian, with language selectable by end-users
2. Dynamic CCS (stylesheet) styles, selectable by end-users
3. Annual, monthly, weekly and daily calendar views
4. Multiple categories for classifying calendar events
5. Recurring and all-day events
6. Role-based user permissions and calendar configuration


dotnet(.Net) Project Source code Downloads and Tutorials

Email Subscrption



Enter your email address:

Delivered by FeedBurner

Feedburner Count

Unique Visitor

Design by araba-cı | MoneyGenerator Blogger Template by GosuBlogger