RE: CRM 4.0 upload file for email attachment

72 views
Skip to first unread message

Floryn

unread,
Jan 25, 2008, 9:47:01 AM1/25/08
to
// get data from file and use ToBase64String to obtain
// encoded string
string encodedData = System.Convert.ToBase64String(bytesFromFile);
// create activitymimeattachment
activitymimeattachment ata = new activitymimeattachment();
ata.activityid= (Lookup (emailid))
ata.filename=..
ata.mimetype=..
ata.body=..
ata.subject=..
Guid ataid = service.Create(ata);
//
// update activitymimeattachment
AllColumns colp= new AllColumns();
activitymimeattachment ataread =
service.Retrive(EntityName.activitymimeattachment.ToString(),ataid,colp);
ataread.mimetype=..
ataread.body=encodedData;
service.Update(ataread);

"Sylvain" wrote:

> Hello,
>
> How can I upload a file to CRM 4.0 for email attachment ?
> In CRM 3.0 we had an UploadFromBase64DataActivityMimeAttachmentRequest to do
> that but now I can't figure how to do this upload.
>
>

Sylvain

unread,
Jan 25, 2008, 10:50:02 AM1/25/08
to
Thank you!
Here is the working code (there was just a little error)

// get data from file and use ToBase64String to obtain
// encoded string
string encodedData = System.Convert.ToBase64String(bytesFromFile);
// create activitymimeattachment
activitymimeattachment ata = new activitymimeattachment();
ata.activityid= (Lookup (emailid))
ata.filename=..
ata.mimetype=..
ata.body=..
ata.subject=..
Guid ataid = service.Create(ata);
//
// update activitymimeattachment
AllColumns colp= new AllColumns();
activitymimeattachment ataread =

(activitymimeattachment)service.Retrieve(EntityName.activitymimeattachment.ToString(),ataid,colp);
ataread.mimetype=..
ataread.body=encodedData;
service.Update(ataread);

Reply all
Reply to author
Forward
0 new messages