Showing posts with label NET. Show all posts
Showing posts with label NET. Show all posts

Tuesday, July 29, 2008

Outlook Programming: how to find the parent message for a reply or forward message.

I'm currently involved in developing Outlook add-in. During that I've faced the problem how to find the parent message for a reply or forward message. The idea is that all messages in a conversation have the same ConversationTopic value, while the ConversationIndex is increased by 5 bytes with each change. Here is the sample that uses a MailItem named lastMailItem and searches the Inbox for a matching parent item.


MAPIFolder inbox = m_applicationObject.Session.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
Items inboxItems = inbox.Items.Restrict("[ConversationTopic] = " + "\"" + m_lastMailItem.ConversationTopic + "\"");

string str = m_lastMailItem.ConversationIndex;
string convIndex = str.Substring(0, str.Length - 10);
foreach (MailItem item in inboxItems)
{
if (item.ConversationIndex == convIndex)
{
// Item is found, add your code here!!
break;
}
}

Hope this will help you lot's.

Monday, June 30, 2008

Tooltip in ASP.NET GridView headers

I was searching for the way show Tooltips for headers of ASP.NET GridView control without using javascript or using unnecessary overhead in code. And I found the way how to do it. When you define columns or your GridView you should use TemplateField instead of BoundField cause it's customizable. In TemplateField you can define HeaderTemplate and put there Label control with needed Tooltip. Here is the code:

<asp:GridView ID="GridView" DataSourceID="ObjectDataSource1" runat="server" AutoGenerateColumns="False" >
<Columns>
<asp:TemplateField SortExpression="ShareCount">
<HeaderTemplate>
<asp:Label runat="server" Text="Nr. of Stocks" ToolTip="Total number of stocks on the market"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("ShareCount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Sunday, June 29, 2008

ASP.NET data binding essentials

<%# %> Syntax

ASP.NET introduces a new declarative syntax, <%# %>. This syntax is the basis for using data binding in an .aspx page. All data binding expressions must be contained within these characters. The following list includes examples of simple data binding from multiple sources:

• Simple property (syntax for a customer):
<%# custID %>

• Collection (syntax for an order):
<asp:listbox id="List1" datasource="'<%#">' runat="server">

• Expression (syntax for a contact):
<%# ( customer.First Name + " " + customer.LastName ) %>

• Method result (syntax for the outstanding balance):
<%# GetBalance(custID) %>

In the preceding examples, the inline <%# %> tags indicate where the information from a specific data source is to be placed in the .aspx page. The following data binding example uses a TextBox Web server control: <asp:textbox id="txt" text=="<%# custID %>" runat=server />

For more information about data binding syntax, see the following .NET Framework Software Development Kit (SDK) documentation:
Data Binding Expression Syntax
http://msdn2.microsoft.com/en-us/library/bda9bbfx(vs.71).aspx