Howto Add an Attachment with Webdav

There is no mechanism to add an attachment in WebDAV. You will need to create/recreate the item using a WebDAV PUT. The text you would be putting would be the mime of the item, which also contains the attachment. It’s useful here to use CDOSYS to create a message and add an attachment – then extract the MIME from the message and use it for the WEBDAV PUT. You will need a header of "translate" set to "f".

If the message already exists, you will need to, you must do a GET on the message stream, which will give you the message + attachments in a string. Next, modify the stream to include a new attachment. After this, the string can be used in a PUT statement to write the attachment.

Comments

  • Anonymous
    May 17, 2009
    The comment has been removed

  • Anonymous
    May 18, 2009
    Hello Antonio; You will need to do a put with the entire message in MIME format.  The entire message will include the full message body, recipients, subjet, etc PLUS each of the attachments as body parts of that message.  You can use CDOSYS to create a message with attachments and then have CDOSYS generate MIME which will be used with a PUT - there should be a sample on this in my blog.   You cannot do a PUT of an attachment by itself - you have to do the PUT with the entire message (message body, headers, recipients, attachments) in mime format.   Thanks, Dan

  • Anonymous
    May 18, 2009
    Thanks for your fast response.... you know some links, tutorials or something for use the cdosys with php... I'm searching on Google, i found a lot of tutorial to use cdosys in asp or generally .net languages but nothing with PHP... (A my think....) If i make a mime message, can i put this message such as an EML file in exchange draft folder and after with MOVE command, move this file in ##DavMailSubmissionURI## ? Many thanks, Antonino

  • Anonymous
    May 19, 2009
    Hello Antonino; You probably will not find many (if any) samples of PHP using CDOSYS.   The best way to send a message with WebDAV is to do the following:  1) Create a MIME message as a string.  This MIME string should contain the full body and attachments. This can be done with CDOSYS, with a third-party API or programatically by programming against the MIME RFCs.  2) Do a PUT using this string into the "drafts" folder.  Be sure to use a unique name.  The message should always be created in the drafts folder initally and not the ##DavMailSubmissionURI## folder. If you create the message in the ##DavMailSubmissionURI## first, it will be sent right away and may not be constructed propery.  3) You may need to do a PROPPATCH to add additional properties to the message which cannot be set via MIME.  What would need to be set depends upon what you are doing.  In most cases, you will not need to do a PROPPATCH.  4) At this time your message should be completely built.  The next step is to do a WebDAV MOVE on the message to move it from the "drafts" folder to the ##DavMailSubmissionURI## folder. Thanks, Dan

  • Anonymous
    May 19, 2009
    ^__^ how can I thank you? is what I wanted to know. You are my hero I'm very happy, my job can proceed... I'm serious, MANY MANY THANKS