InfiniTec - Henning Krauses Blog

Don't adjust your mind - it's reality that is malfunctioning

Sending mails with WebDAV with recipients in the BCC field

This article on MSDN show how to send an email through a users mailbox using the DAV submission URI. Basically, you perform these steps:

  1. Construct the email following RFC 2822 (and RFC 2045 for more complex mails)
  2. Use the PUT command to upload the mail to the drafts folder of a users mailbox
  3. Use the MOVE command to move the mail to the DAV submission url.

The mail will then be sent to the recipients specified in the header of the mail using the TO: and CC: headers.

If you try to include a BCC: header to send the mail unnoticed of the other recipients, you will get an Unprocessable Entity error on step 3. This is because the BCC information is an envelope field rather than a header field (See RFC 2821 for more infos about SMTP envelopes and mail header).

To cope with this, you'll have to perform two things:

  1. When uploading the mail to the drafts folder using the PUT method, be sure to specify a content type of message/rfc822.
  2. Before moving the mail to the DAV submission uri, issue a PROPPATCH command on the mail in the drafts folder and set the field urn:schemas:httpmail:bcc to the intended BCC recipients. As described in the article, this is a comma delimited list of all recipients in the form "Someone" <someone@example.com>.

Technorati:

Posted by Henning Krause on Tuesday, September 4, 2007 12:00 AM, last modified on Tuesday, September 4, 2007 12:00 PM
Permalink | Post RSSRSS comment feed