Custom workflow to read XML attachment CRM 2011 Online RRS feed

  • Question

  • Hi,

    I would like to deploy a custom workflow in our CRM 2011 Online system to read the contents of an XML attachment when an email is received. The XML fields would then be returned to the custom workflow.

    Does anyone know of any sample code anywhere I can use to get me started on this?

    The custom workflow would be run whenever an email record is created.

    Thanks in advance for any help.


    Tuesday, June 4, 2013 10:52 AM


All replies

  • Tuesday, June 4, 2013 1:23 PM
  • Hi Jason,

    Thanks for providing those links.

    I've already created one custom workflow to create a new case when we receive an email to our support email address so I'm fairly happy with how to build a custom workflow. I was really wondering specifically how I can reference an XML attached file in my code? e.g at present I have implemented the following code:

        if (Emailid != null && context.PrimaryEntityName == "email")
                        Guid Mailid = context.PrimaryEntityId;
    			// do more stuff here

    How would I reference an XML attachment to an email?

    Many Thanks,


    Thursday, June 6, 2013 9:48 AM
  • Something like:

    private EntityCollection GetAttachments(IOrganizationService service, Guid id)
    	//Query for the attachments
    	QueryExpression query = new QueryExpression()
    		EntityName = ActivityMimeAttachment.EntityLogicalName,
    		ColumnSet = new ColumnSet("filesize", "filename"),
    		Criteria = new FilterExpression
    			Conditions = 
    				new ConditionExpression
    					AttributeName = "objectid",
    					Operator = ConditionOperator.Equal,
    					Values = { id }
    	return service.RetrieveMultiple(query);

    Used here:

    foreach (ActivityMimeAttachment a in attachments.Entities)
         //get file contents
    	 //a.Body is the binary content of the file you'll need to covert into a readbale format

    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Thursday, June 6, 2013 2:27 PM