ISoapAttachment::Body Property

[propget] HRESULT Body([out, retval] VARIANT * pVal);
[propput] HRESULT Body([in] VARIANT body);

This contains the actual attachment data, for small attachments contained within memory, this is an array of bytes, for large file based attachments, this is the fileName of the attachment. You can use the Located property to see if the attachment is in memory or on disk.


Return Values

An array of bytes containing the attachment data, or the fileName of the attachment


Sample Code

' create and initialize the SOAP envelope
set e = CreateObject("pocketSOAP.Envelope.2")
e.setMethod "doImage", "urn:AttachmentService"

' create the attachments object, and switch to MIME formatted attachments
set a = CreateObject("pocketSOAP.Attachments")
a.format = formatMime

' create the parameter that has the attachment attached to it
set n = e.parameters.create("gif", empty)

' create the attachment, and create a reference between the attachment and the parameter
n.href = a.Request.Create ("c:\picture.gif", tnfMediaType, "image/gif").Uri

' set the required SOAPAction, then give the transport object, to the attachments object
t.Soapaction = "urn:AttachmentService/doImage"
set a.Transport = t 

' now we call send/receive/parse through the attachments object, so that it can 
' inject/extract the attachments before sending them through the transport
a.Send "", e.Serialize

' parse the results
e.parse a

' find the response attachment
set theAttachment = a.response.find(e.parameters.item(0).href)
if theAttachment.Located == attInMemory then
	msgbox "the attachment is " & Ubound(theAttachment.Body) & " bytes"
	theAttachment.Save "c:\xmlbus.gif"
end if
msgbox "the attachment is saved to " & theAttachment.Body


See Also

The ISoapAttachment Interface | 




Copyright © Simon Fell, 2000-2004. All rights reserved.