function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
wfreschwfresch 

Upload a file attachment for Salesforce in C#

 

I've seen this example to build and send an attachment to Salesforce in Java, but how is this accomplished in C#?

 

I'm also using this page as a reference, but I still don't know how to finish the last part where I try to create and save the attachment.

 

SoapClient client =newSoapClient();
LoginResult lr = client.login(newLoginScopeHeader(), username, password);

FileInfo
fileInfo =newFileInfo(myFileLocation);
FileStream stream =File.OpenRead(myFileLocation);
byte[] byteArray =newbyte[fileInfo.Length];
stream.Read(byteArray,0, byteArray.Length);

Attachment
attachment =newAttachment();
attachment.Body= byteArray;attachment.Name= myFileName +".txt";attachment.IsPrivate=false;

SaveResult saveResult = client.create(new sObject[]{ attachment })[0];
wfreschwfresch

Also, I've seen a lot of examples that make use of a SforceService reference, but my wsdl only allows me to use a Salesforce "SoapClient" object.

cplusplus_pleasecplusplus_please
2 links that might help you:
http://boards.developerforce.com/t5/Perl-PHP-Python-Ruby-Development/How-to-upload-an-attachment-as-a-Salesforce-Document/td-p/257653

http://salesforce.stackexchange.com/questions/8137/upload-and-attach-a-file-to-an-account-or-opportunity



=============================
Developer for www.voicent.com
Voicent provides CRM, auto dialer, predictive dialer, reminder, and call center solution that is suitable for anyone in any level
Voicent strives to meet customer demands to integrate Voicent software with CRM of their choice.