Q:

how to display salesforce attachments in asp.net website to download

we are creating asp.net website which uses salesfoce webservice api and pull all the information. We have a functionality within the site to display a contact "notes and attachments" which can be downloaded. I have been googling a lot about it, but no use.
Can any one guide me please.?
thanks,

A:

You have to query the Attachment table, either directly:
SELECT Id, Name, Body, BodyLength, ContentType, CreatedBy.Name, CreatedDate, Description, Owner.Name, ParentId
FROM Attachment 
LIMIT 10

Or indirectly with a subquery:
SELECT Id, Name, Email, (SELECT Name FROM Attachments ORDER BY CreatedDate DESC)
FROM Contact
LIMIT 10

The actual content of the file is stored in the Body column, base64-encoded. You'll have to decode it and (based on content type?) save as text / binary file, server to the user with the proper content header...
The inclusion of the Body column slows things down a bit - I'd recommend you skip it initially in the "see attachments related list" part of your ASP application and retrieve them (by Id for example) only when user actually wants it... I've noticed that you can get just 1 row returned (initially) with Body queried for so if you really want to do it all in one go - check out the documentation for queryMore() function and make sure your app has processed whole query locator ("cursor" if you're familiar with that word).
So, the above should work both in SOAP API and REST API as long as you can send queries (you didn't specify which one you use... "webservice api" sounds like you're limited to using few selected Apex classes exposed as webservice). Additionally REST API has special retrieve() command.

