Skip to main content

Posts

Showing posts from August, 2004

Creating a new folder in a mailbox if one doesn't exist

I've had this question from a few people that wanted to do this in a event sink, its acually really simple to do with a little bit of ADO/Exoledb code. To create a folder in a mailbox using ADO you can use the adCreateCollection option in your record open statement. The following two lines would create a folder in a mailbox. set rec = createobject("ADODB.Record") rec.open "file://./backofficestorage/domain.com/MBX/mailbox/newfolder/", ,3,8192 The options included in the open statement are 3 which is adreadwrite and 8192 which is adCreateCollection (hex 0x2000) If you try this code and the folder already exists you will get an error returned stating that the object already exists. So if you want to run the above code to create the folder only if the folder doesn't exist and not return an error if it does all you need to do is combine adCreateCollection with adOpenIfExists. eg set rec = createobject("ADODB.Record") rec.open "fil

vCalendar with CDO and Script

I’ve been playing with vCalendar and iCalendar with Exchange to solve a few problems and I found it was pretty interesting so I decided to write about a few things I’ve learned. Background Some good background information on vCalendar can be found here vCalendar and Outlook (good general background on what it is) IMC Product Development Information (This is the best site for vCalendar info and contains documentation of the current implementation) IMC ietf-calendar page (Good read on iCalendar) And last but not least this from the exchange SDK Basically with Exchange each appointment in your calendar has a vCalendar formatted body part. Putting it to use. There are plenty of things you can do with vCalendar formated files the most obvious is to use them to import and export calendar appointments where other methods can’t be used. A simple CDO/ADO script that would go though and export all the appointments in a calendar for the past year (past and future

Calendar RSS feed Event sink

Somebody emailed me about using the public folder RSS event sink from one of my previous posts on a mailbox calendar. This sounded like a pretty cool idea and I could see some good applications so I decided to blog what I came up with in response to this. A few things need to be changed from the original script the main one would be instead of the sink generating a feed of the last 7 days worth of posts in a public folder you would want it to generate a feed of the next 7 days worth of appointments in the calendar. Also some of the email fields needed to be dumped in favor of appointment start and end times. The third thing that needs to be done was to add some code to do a timezone adjustment because Exchange stores all appointment start and end times in UTC format. And last but not least a function was added to convert the adjusted query date values into ISO date format which is required for the Exoledb SQL query string. The Query string itself was completely rewritten to grab ap

Loading a Message in CDO from a text variable

This is something i learned today, Loading a message from a file is well know and documented here using the ADO stream object loadfromfile method. But what if say instead of the message being stored in a serialized format in a eml file its stored exactly the same way in a SQL database. The way I found that worked was to first create a new stream object and open it, write the text into the stream using stream.writetext (in this case it was a serialized version of a email exactly the same as a eml file yet stored in a database field). An then you flip the stream type to binary which converts the stream to binary for you and then you can use the normal open message from ado stream method. Here's what it look likes set stm = createobject("ADODB.Stream") set msgobj = createobject("CDO.Message") stm.open msgstring = rs.fields("messagebody") stm.type = 2 stm.Charset = "x-ansi" stm.writetext msgstring,0 stm.Position = 0 stm.type = 1

Using X headers with Exchange

X-headers are user defined fields that can (and are) inserted into a mail header that can serve a number of roles and purposes. Some common ones that are used are x-mailer which descibes the name of the software used to send that email and x-scl which is used to store the IMF SCL value when a message is archived to the ucearchive directory by the IMF (note this is not used to pass the SCL between servers this is done though the xexch50 blob during message transfer). If you want to make use of a x-header in a Exchange sink or CDO script its pretty easy. First off all you need to know is what the name of the x-header is. If your not sure i find the best way to find out is to look at a serial version of the email. For this you can save the message to a eml file using a script like this and then open the eml file in notepad. set msgobj = createobject("CDO.Message") msgobj.datasource.open mailurl set stm = msgobj.getstream() stm.savetofile "d:\myemail.eml"

Detecting BCC's with a SMTP event sink

A couple of weeks ago I blogged this about BCC's and CDOEX, One of the questions that comes up when you start to deal in BCC's is can you detect a BCC programmatically for instance in a anti-spam event sink or if you are worried about confidentiality in an email that was sent. The answer is kind of. For instance you could implement a SMTP event sink on your forward facing Exchange /SMTP box that could detect if a email comings into your organization was being BCC to anyone in your domain. You do this by using the http://schemas.microsoft.com/cdo/smtpenvelope/recipientlist envelope field. This field will contain a list of all the recipients of a message that was submitted by the client (or sending mail server) before expansion of the address has been performed (or categorization in Exchange speak). On a inbound message this would only be the recipients that where in your domain that the SMTP server could deliver to. If you where to compare the recipientlist to the to and cc fi
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.