-1

Is possible to Get / Update an existing Attachment using C#?

If it is can any one share some sample code or resources?

6

A quick Google search for 'c# salesforce attachments' returns results like:

https://stackoverflow.com/questions/12525032/add-attachment-for-new-contact-in-salesforce-using-c-sharp

http://www.joshuapyle.com/2012/09/add-attachment-for-new-contact-in-salesforce-using-c/

These all cover adding / updating an attachment.

Retrieving will work the same as getting any other object data and then just base64 decoding the file body field.

More info on the attachment object can be found here: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_attachment.htm

5
  • Hi Jon Hazan, Thanks for your response. The above 2 links you have provided is attachment related query posted by me. Please check. That is related to "how to attach a new file". Now I am asking "how to get/update the existing attachment".
    – Haridharan
    Oct 4 '12 at 7:10
  • I tried with retrieve() method. sObject[] result = connection.retrieve(string fieldList, string sObjectType, ID ids[]); It is working for getting other fields like email, Name. But I am not able to use the "NotesAndAttachment" field. Please find my below code. sObject = salesForce.retrieve("LastName,Email,NotesAndAttachments", "Contact", new string[] { ContactId });
    – Haridharan
    Oct 4 '12 at 7:24
  • @Haridharan Updating and adding are almost identical. As for retrieving you need to access them via the Attachments object. Retrieve the Attachement object records that have a ParentId that is set to your ContactId.
    – Jon Hazan
    Oct 4 '12 at 9:50
  • Can you please let me know how to retrieve attachment object? ContactId is parentId only. below code throws exception. sObject = salesForce.retrieve("LastName,Email,Attachment", "Contact", new string[] { ContactId })
    – Haridharan
    Oct 4 '12 at 10:51
  • 2
    @Haridharan You should do some googling and look up querying salesforce in C#. i.e. sObject = salesforce.query("SELECT Body FROM Attachment WHERE parentId = '<Your ID Here>'"); - more info: salesforce.com/us/developer/docs/api/Content/…
    – Jon Hazan
    Oct 4 '12 at 10:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.