Hi all,
I've successfully created a Case from an incoming Email using C#, but I have a few fields/entities I'm unable to add to this newly created case. So far here is what I have:
Entity returnCase = new Entity("incident"); returnCase.Attributes.Add("title", emailMessage["subject"]); returnCase.Attributes.Add("customerid", emailMessage["regardingobjectid"]); returnCase.Attributes.Add("caseorigincode", new OptionSetValue(2)); returnCase.Attributes.Add("casetypecode", new OptionSetValue(3));
Which works fine; but my requirements are that I also attach the original email to this new Case.
My other requirement is that I set the subject to a default. (I've used the same code as "customerid", but it will not set the lookup to what I specify)
Does anyone know how to do these things for a case?
Thanks,
Bmckie
EDIT: HALF-SOLVED, HALF!
The solution to attaching the email to the Case was to add the following:
Relationship relationship = new Relationship("Incident_Emails"); EntityReferenceCollection relatedEntities = new EntityReferenceCollection(); relatedEntities.Add(new EntityReference("email", emailRef.Id)); service.Associate("incident", caseId, relationship, relatedEntities);