Skip to main content

Posts

Showing posts from 2007

Mailbox Folder Size comparison Powershell GUI

While updating the mailbox size GUI the other week and getting a grip on the Get-Mailboxfolderstatitics cmdlet I had a few ideas of some other cool stuff you could do with this. For example if I used this cmdlet to get all the mailbox folders sizes on a server and then put them into a ADO.NET datatable I then have the ability to do a whole bunch of funky data manipulation that can be used to produce a whole bunch of useful information. For example I can show in a datagird a comparison between the sizes of everybody’s inbox, Sent Item, Deleted Item’s etc. Which allows me to answer questions like? Who has the largest inbox on the server Which users have too many items in their Inbox How much each user has sitting in their deleted Items folder One of the Properties Get-Mailboxfolderstatitics also allows you to see is the age of the newest item in the folder. So this can come in handy if you’re looking for mailboxes that might no longer be in use because you will be able to see and c

Exchange 2007 Mailbox Size Powershell Form Script version 3

Version 4 has now been released that includes mailbox quotas here I've been promising to update this for a while to fix a few issues and fulfill of few requests . I've switched the FolderSize code from using EWS to query the foldersizes to now use the Get-MailboxFolderStatistics Cmdlet instead. This makes the code a lot more functional and easy to use and doesn't require all that messing around with Impersonation and SSL (I kind of missed the whole Get-MailboxFolderStatistics cmdlet but it was fun building the EWS stuff anyway). I've also now used DataGrids to display the result which means it is now sortable (Yeah!) you can now sort to your hearts content on any of the displayed columns. The only thing with Datagrid 's because of the threading issue with Powershell i couldn't use the click event so to display the foldersize you need to select the mailbox you want to show and then click the Get Folder Size button. Another feature I've added is the ability

Script to find and fix mismatches between the Reply Address and Active Directory Mail property

The following script is an ADSI powershell script that can be used check and update any user accounts where you have a mismatch between the mail property in Active Directory and the Reply address that has been set for a users mailbox. If you’re running Exchange 2007 you might want to look at using Set-Mailbox –ApplyMandatoryProperties instead. This script is pretty simple it will look at any mail-enabled users and check the active directory mail attribute against the Identified Reply address. If any mismatches are found it will then prompt to ask if the user wants to update the Active Directory Mail property to be the same as the Reply Address. To guard against null address if a null property is founds the script will just echo out the account that is have a null property. I’ve created two version of the script the first just uses ADSI so it will work on any version of Exchange and will to scan the current domain the executing workstation is in the second uses get-mailbox in Exch

Uploading a document into a SharePoint Document library from a Exchange 2007 Transport Agent.

SharePoint servers these days are multiplying like rabbits while Sharepoint is a great place to put and index information breaking habits and making sure you have a central repository of things is always a challenge. What this agent does is looks at any email which has any Pdf attachments that have the word “quote” in the filename if these emails have any external recipients this document will get uploaded into a specific SharePoint’s sites shared documents library. So this allows me in this case to have a central repository of all the quotes sent out via email. To make sure the documents that are being uploaded have a unique filename the processing time is added to the filename of the document at the time it’s uploaded to SharePoint. Because programmatically uploading a document into SharePoint isn’t that straight forward To upload the document into the SharePoint Document library itself I’ve use the S.S. Ahmed cool WSUploadservice which is free,easy to install and use you can get

Exchange 2007 Content Agent Log Message Tracker Gui

One of the cool features from a logging perspective on Exchange 2007 is the ability to log the SCL of every message when you have the Content Filtering Agent enabled (and also logging enabled). There is a Exchange Management Shell powershell cmdlet for reading these logs called get-agentlog which gives a good cmdline experience but as these logs are something you might want to check on a regular basis and the information contained in them is a little unwieldy to display in a cmdline environment I decided to put together a little GUI to make my life a little easier. I based the GUI on my Exchange 2000/3 WMI message tracker and I was able to carry over a lot of the cool little aggregation functions of this utility using most of the same code with a few tweaks here and there. What this script does is creates a Winform and adds a whole bunch of controls to that winform such as datapickers, textboxes, checkboxes,labels and buttons. Its then wires ups some functions to the button clicks

Adding an attachment in a Transport Agent on Exchange 2007

This is a quick post to give an example of something that from the outset I would have thought would be easy but for some reason took me a little time to get my head around. Having been using CDOSYS/EX for a number of years adding a attachment to a message Is as easy as just using the addattachment method and specifying the filepath and the class will do the rest and add that attachment to the message. When working in a transport agent with the Microsoft.Exchange.Data.Transport.Email class to add an attachment you can use the attachment collections add method . There is an overload for this method that allows you to specify the filename which I thought would mean that this would work like CDOSYS’s addattachment method which didn’t turn out to be the case. Using this overload just gives you a blank attachment object with the filename property set. So to add an attachment within a Transport agent you first need to open the file in question and read-in the stream of bytes from the file

Adding Document Favorite links for Direct File Access in OWA 2007 via a script

Direct File access is a pretty cool feature of OWA 2007 although may not be the easiest thing for your average user to get their head around. Somebody asked a question about pre-populating the favorites for a user which is a pretty good idea (actually when you think about it you really want something that’s policy driven). Currently there is no really easy or supported way of doing this programmatically. The document links themselves are stored in a storage item with a messageclass of IPM.Configuration.Owa.DocumentLibraryFavorites in the associated folder collection of NON_IPM_Subtree root of a mailbox. On this storage item there is a binary mapi property 0x7C080102 and the links are stored in a XML document. I decided to see if I could write a script that could open this storage item and then add some nodes into the already existing property or create the property if it didn’t exist. The format of the doclib node looks something like <docLib uri="file://sername/direct

Processing embedded attachments in a Transport Agent

Continuing on from my other post last week this is a little bit more of an advanced Transport agent that can process attachments within embedded messages down to any depth. Most of the code is the same as last week except that the structure of the code has been changed so each message and embedded message is processed by the routine. To see if a attachment has an assoiciated embeeded message all you need to do is check the EmbeddedMessage property on each message. The one thing that I found interesting is when processing an embedded message vs. just processing the message that caused the Agent to fire is that there is no underlying MIME document so the code I had that was saving out the message to a separate directory using the MIME document in this case wouldn’t work for an embedded message. As I was really only interested in processing attachments this was not so much of a problem but its one thing to be careful of if you do what to processes embedded messages. For details of what th

Email and Attachment Archiving with a Transport Agent on Exchange 2007

I’ve been continuing on with building and learning about Transport Agents over the past couple of weeks and thought I’d share an agent I’ve found useful. The following agent is a simple archiving agent it saves the serialized version of the message from the Mimedocument class to an eml file in a directory assigning it a GUID as a filename to make sure its unique. It also enumerates though the attachments of a message and saves them to a separate directory using the attachment filename and the message guid to link the message and attachments. I also added some code into to delete pdf files that where smaller than 20 KB this was for testing purposes but it’s something I’ve used in the past in SMTP sinks to overcome certain issues. Like the last Agent I posted this is a Routing agent I’m running on Hub Server the code is relatively simple to follow. To do the attachment processing I’ve used the new EmailMessage class that’s part of the Microsoft.Exchange.Data.Transport.Email namespace.

Adding an X-header in an Exchange Routing Transport Agent in Exchange 2007

This week I’ve been looking at Transport Agents which are the replacement to Transport Event Sinks in Exchange 2007. After the initial struggle of finding some decent information to get going these Agents are surprising easy to code and have a bunch of powerful functions that are more readily available then they were when compared to SMTP transport Event Sinks. Getting Start info If you’re looking for info on getting start the first place is this simple sample . One piece of advice is before you look at installing a Transport Agent making sure you know how to disable or remove one first. There are two types of Transport Agents Routing and SMTP which one you use really depends where in the Transport Pipeline you want to intercept the message. I choose a Routing Transport agent because I wanted to be able to add an X-header to a message regardless of whether the message arrived via SMTP or if it was sent locally on a Mailbox server (if you are looking to do this in a SMTP Transpor

Assigning categories based on the Attachments in a Message via a CDO 1.2 script

This is part 2 of a 2 part post of a few scripts to assign different colored categories to messages based on the type of attachments a message has. See the first post for information on how modify the Outlook 2007 categories’ This script handles enumerating the existing messages within a mailbox and then assigning categories (or keywords) based on the attachment types on the message. When I used this script I did every message in my mailbox which worked okay but because I was using Outlook in Cache Mode updating a lot a messages this way caused a major re-syncing or the cache (e.g. it seemed to pull down every message again that was updated with an attachment which can consume a lot of bandwidth if you have a large mailbox with large attachments). While this may be okay for some people this could cause some havoc in some networks so with this script I put a filter value so it will only update the messages that are less then 1 month old in the inbox. This could still be a conside

Adding Categories to the Master categories list in Outlook 2007 with a CDO 1.2 script

This is a two part post that I thought I’d separate this idea came from someone who asked about how you could group messages by their attachment types. Normally this would be a pretty hard thing to achieve manly because of the way attachments are stored doesn’t lend itself well to being grouped by in a search folder or an Outlook Customize view. But this got me thinking about what if you could use the new colored category feature in Outlook 2007 instead. Eg for each attachment type you have a separate color and Label. This works out pretty cool because you go from being able to look at your email and seeing that there is an attachment eg the paper clip icon to being able to look at a message and if you see a blue category mark you know that message has got an attachment and it’s a word document if it’s a green mark you know it’s a Excel document. You can then also create Views or Search folders based on the attachment categorization you could also could create an event sink or Notif
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.