create excel email attachment CRM 2011 question? RRS feed

  • Question

  • In CRM 2011 online, is it possible to create excel type of email attachment? The main point is that the excel be created dynamically and be opened for inserting data. 

    - I am creating a plugin to create email message 

    - I need to create an excel on the fly and insert some data in it (per query) and send this excel as an email attachment. 

    I have samples from  msdn on how to create email message and attachments (i have created many of them). However, I haven't created any excel attachment. This excel cannot be stored in a local drive as the plugin runs on the CRM online (cloud). 

    - i should be able to create excel with columns as per query (say my open contacts)

    - insert rows and columns into this excel and send this as an email attachment.  Is this possible 

    • Edited by CRM elite Friday, July 20, 2012 5:18 PM
    Friday, July 20, 2012 5:17 PM

All replies

  • I did that a few months ago. Here is the sample code from sdk

    Annotation setupAnnotation = new Annotation() { Subject = "Example Annotation", FileName = "ExampleAnnotationAttachment.txt", DocumentBody = Convert.ToBase64String( new UnicodeEncoding().GetBytes("Sample Annotation Text")), MimeType = "text/plain" };

    The documentbody attribute is containing the file contents.

    What you need to do is to use string builder to create the the contents and convert it into ToBase64String without saving as a physical file anywhere.

    I hope this helps.

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com

    • Proposed as answer by Amreek Singh Saturday, July 21, 2012 8:25 AM
    • Edited by Amreek Singh Saturday, July 21, 2012 8:25 AM
    Saturday, July 21, 2012 8:24 AM
  • Hello Amreek, I was using the  toconvertobase64. But the issue I was facing was - that I need, on the fly create excel, and   insert data into the excel and without storing it anywhere, to be able to read the block of data. 
    Saturday, July 21, 2012 5:05 PM
  • I managed to get the stringbuilder however, when I open the file, it is showing the xml format in a single line (i do see all the columns and values) but it is in single line iwth td and tr etc.,! 
    • Edited by CRM elite Saturday, July 21, 2012 8:18 PM
    Saturday, July 21, 2012 6:09 PM