Downloading attachments, some progress...
Quick refresher: I'm being sent a number of files in e-mail which is directed
to a public folder. I need to extract the attachments once a day.
I have made some progress. I have figured out how to open the folder using
ODBC and made queries against the message list, picking out the correct
messages; ones received today from particular addresses. This, as expected,
returns a single message "row".
I am now trying to retrieve the attachment. I am going to try to use WebDAV
to get it, because that seems to be the only one that works on any of these
machines. Here is what I do...
rstEmails.Open "SELECT * FROM theTable WHERE [From] LIKE
'%@thesender.com' AND [Has Attachments]=True AND [Received]>=#" & date & "#
AND [Received]<#" & DateAdd("d", 1, date) & "#", conn, adOpenStatic,
adLockReadOnly
' use the subject to create an URI
Subject = Trim(rstEmails!Subject)
Subject = Replace(Subject, " ", "%20")
Uri = "http://x4.ourdomain.com/public/theFolder/" & Subject & ".eml"
Set req = CreateObject("microsoft.xmlhttp")
req.Open "X-MS-ENUMATTS", Uri, False
req.send
Set ret = req.responseXML
fname =
ret.getElementsByTagName("e:attachmentfilename")(0).FirstChild.Text
When I try this code against a test file that I sent to the folder,
everything works fine and I get the file back. However, when I try this
against a real message, I get nothing in
ret.getElementsByTagName("e:attachmentfilename"), and looking at the ret
object itself, I see that the childNodes is zero length, which I assume is
not correct. Yes, the test file and real file both have a file attachment --
which is why the WHERE works.
The only difference I can see is that the "Message.Class" for the message I
sent is "IPM.Note", whereas the real one came in as "IPM.Post". Would this
make a difference?
Maury
date: Tue, 19 Feb 2008 07:28:01 -0800
author: Maury Markowitz