| Author |
Message |
Nelson
Joined: 14 Jun 2005
Posts: 16
|
Posted:
Tue Nov 29, 2005 4:17 pm Post subject:
Detect email attachment via WebDAV |
|
|
I'm retreiving/saving attachments to emails via WebDAV and am currently ignoring any embedded attachments (where the attachment type d:x37050003 = 5). If this value is 1 then I consider it a valid attached file. However, at times I'm getting what appears to be a valid attachment, but is really an image that is an "email background". I want to ignore these types of attachments. The trick is that I sometimes get images as attachments that I don't want to ignore (i.e. I can't just ignore .JPG or .GIF attachments). Any ideas on how I can detect if an attached image is being used as an email background? Currently I getting the following as part of my XML webDAV response:
<a:propstat>
<a:status>HTTP/1.1 200 OK</a:status>
<a:prop>
<d:x3704001f>ClearDay.JPG</d:x3704001f>
<d:x37050003 b:dt="int">1</d:x37050003>
<d:x370b0003 b:dt="int">-1</d:x370b0003>
<d:x370e001f>image/jpeg</d:x370e001f>
<d:x3712001f>011101c5eeda$9da1e040$6401a8c0@YOURF2BB931F71</d:x3712001f>
<d:x37140003 b:dt="int">4</d:x37140003>
<d:x0e200003 b:dt="int">7832</d:x0e200003>
<d:x0e210003 b:dt="int">0</d:x0e210003>
<e:attachmentfilename>Clear Day Bkgrd.JPG</e:attachmentfilename>
<f:cn>Clear Day Bkgrd.JPG</f:cn>
</a:prop>
</a:propstat>
Is there something I can use here? Do I need to obtain more data?
Thank you very much,
Nelson
|
|
| Back to top |
|
 |
Dave Kane [MVP - Outlook]
Guest
|
Posted:
Thu Dec 01, 2005 1:59 am Post subject:
Re: Detect email attachment via WebDAV |
|
|
The only way I know is to get the HTML body of the message
(urn:schemas:httpmail:htmldescription) and look for a "background" property
within the <body> tag. If your attachment is a background image it will be
referenced. For Outlook stationery you'll see something like this
<body background="cid:image001.jpg@01C293EE.4F067D00" ...
where the value between cid: and @ will be the name of your attachment |
|
| Back to top |
|
 |
manju
Guest
|
Posted:
Tue Dec 20, 2005 5:58 pm Post subject:
Re:Detect email attachment via WebDAV |
|
|
Can u post the code how to copy attachments to local folder, I am using VB,
I can able to get the path.
Thaks in Advance
|
|
| Back to top |
|
 |
Nelson
Joined: 14 Jun 2005
Posts: 16
|
Posted:
Tue Jan 10, 2006 6:20 pm Post subject:
Saving an attachment |
|
|
Sorry for the late reply. Been away for the Holidays. If you have the URL to the attachment you want to save you can send it as a parameter to the following function along with the filename you want to save it as:
'---------------------------------------------------------------------------------------
' Procedure : SaveAttachment
' Purpose : Performs a GET request on an attachment and saves it to the working folder
' Params : sRef = URL to attachment
' sFileName = Filename (without path) to save attachment as
' Returns : True if successful, False if fail
'---------------------------------------------------------------------------------------
Private Function SaveAttachment(ByVal sRef As String, ByVal sFilename As String) As Boolean
Dim req As MSXML2.XMLHTTP40
Dim nFileNo As Integer
Dim bytFileBuf() As Byte
Dim sErrMsg As String
On Local Error GoTo EH
'Initialize request object
Set req = New MSXML2.XMLHTTP40
'Request attachment
req.open "GET", sRef, False
req.setRequestHeader "Content-Type", "text/xml"
req.setRequestHeader "translate", "f"
req.Send
'Check GET results
If (req.Status = 200) Then 'OK
Debug.Print "Status: " & req.Status
Debug.Print "Status text: " & req.statusText
'Save attachment (binary file)
nFileNo = FreeFile
Debug.print "Saving attachment: " & sFilename
Open App.Path & "\" & sFilename For Binary Access Write As nFileNo
bytFileBuf() = req.responseBody
Put nFileNo, , bytFileBuf()
Close nFileNo
SaveAttachment = True
Else
Debug.print "Could not save attachment"
Debug.Print "Status: " & req.Status
Debug.Print "Status text: " & req.statusText
Debug.Print "Response text: " & req.responseText
End If
GoTo EXIT_PROC
Resume 'for debugging
EH:
sErrMsg = Err.Number & " - " & Err.Description & vbCrLf & "Line#: " & Erl
Select Case Err.Number
Case Else
sErrMsg = "Unexpected error in procedure SaveAttachment of Class Module clsMailboxProfile" & vbCrLf & sErrMsg
End Select
EXIT_PROC:
Set req = Nothing
End Function
Hope this helps you.
Best Regards,
Nelson |
|
| Back to top |
|
 |
|
|
|
|