Friday, July 23, 2004

BCC's with CDOEX

This one pops up now and again and can be a little bit of a pain to deal with in CDOEX. In the good old days of CDO 1.2 you could access the recipients collection of an email directly but with CDOEX you can't really do this, you only have a few properties which you can access. On a message the BCC field is an envelope field that you usually don't really care too much about, but when it comes to tasks and meeting requests the BCC field takes on a new perspective. In a task the BCC fields gets used for the StatusOnCompletionRecipients which controls who gets a task completion messages when a task is marked as complete and in a Meeting the BCC field is the resources field.

With meeting requests and appointments you can access the recipients collection via the IAttendees interface. So to add a BCC some code like this will work

Set appt = CreateObject("CDO.Appointment")
Set Atnd = Appt.Attendees.Add
Atnd.Address = "resource@yourdomain.com"
Atnd.Role = 2
Atnd.Type = "resource"


For a task you can't really do this but one way around this if you are creating a task (remembering that tasks aren't really supported in CDOEX anyway) is to first create a appointment add the number of people you want to the BCC and CC and then flip the messageclass and davcontent class values and save the item as a task. The only drawback with this method is you end up with a lot of redundant message properties and it only works on creation.

Set appt = CreateObject("CDO.Appointment")
Set Atnd = Appt.Attendees.Add
Atnd.Address = "completionnotify@domain.com"
Atnd.Role = 2
Atnd.Type = "resource"
Set Atnd1 = Appt.Attendees.Add
Atnd1.Address = "updatelist@domain.com"
Atnd1.Role = 1
Atnd1.Type = "Individual"
with appt
.Fields("DAV:contentclass").Value = "urn:content-classes:task"
.Fields("http://schemas.microsoft.com/exchange/outlookmessageclass").Value = "IPM.Task"
.Fields("urn:schemas:mailheader:subject").Value = "Test Task"
.Fields("urn:schemas:httpmail:textdescription").Value = "Blah"
.Fields("http://schemas.microsoft.com/mapi/proptag/0x82D9000B").Value = false
.Fields("http://schemas.microsoft.com/mapi/proptag/0x82BF0005").Value = 0
.Fields("http://schemas.microsoft.com/mapi/proptag/0x82C00003").Value = 0
.Fields("http://schemas.microsoft.com/mapi/proptag/0x82670003").Value = 0
.Fields("http://schemas.microsoft.com/mapi/proptag/0x82C00003").Value = 0
.Fields("http://schemas.microsoft.com/mapi/proptag/0x82C10003").Value = 0
.Fields.update
.datasource.saveto "file://./backofficestorage/yourdoain.com/mbx/mailbox/tasks/taskurl.eml"
end with

 
A better way to handle this might be to use WebDAV which is not inhibited in the same way in regards to BCC's.