You need to sign in to do that
Don't have an account?
CarlSpoon
Download and Upload Attachment Sample Code in VB.Net
Does any one have a sample code in VB.net on how to download/upload attachments from a customer controller (NotesAndAttachments relatedlist)?
I saw a sample code in Php which I modify to VB.NET; however, the Body and BodyLength of the attachment object are always equal to Nothing, even though the file in SalesForce has a file size.
Here is the sample code:
Dim sqlstr As String = "Select p.CreatedBy.Name, p.CreatedDate, p.Id, p.ParentId, p.OwnerId, p.IsDeleted, p.Name,p.LastModifiedBy.Name From Attachment p Where p.CreatedDate > " & strLastRunDate
Dim qr As QueryResult = Nothing
qr = binding.queryAll(sqlstr)
Dim MaxRec as Integer = qr.records.Length
For i = 0 To MaxRec - 1prAttchObj = qr.records(i)
'Problem!! prAttchObj.Body is always = Nothing
If Not IsNothing(prAttchObj.Body) Then
'NewRec.FileBody is of type Byte[]
newRec.FileBody = prAttchObj.Body
.
.
.End If
Next
Here is the definition of the object:
Dim prAttchObj As SandBox.Attachment