Answered by:
CRM 2011 workflow - email - sharepoint integration

Question
-
Hi
I need to create a workflow to send an email based on certain logic to users. This seems fine. But, I also have to attach a specific document from a sharepoint location into this email. This document has to pertain to a sepcific record in the account-customentity-relationship. Are there any examples I can refer to? Thanks
Basically, how can I attach a document from sharepoint into an email created by a workflow.Tuesday, August 30, 2011 8:43 PM
Answers
-
Hi,
Here's how you do it
1. Instantiate CRM Email object and set the mail properties from your Account record
2. Instantiate SharePointDocumentLocation (CRM SDK class) object and pass RegardingObjectId as your customEnitityId
3. Once you have the URL of your sharepoint document, use the code below to get its binary object
http://www.dotnetking.com/TechnicalComments.aspx?LogID=352
4. Once you have binary (stream or bytes) with you populate an ActivityMimeAttachment (CRM SDK) class
5. Connect 4 to 1 and your email is ready to be sent.
Manny Grewal || Australia- Proposed as answer by Manny Grewal Wednesday, August 31, 2011 5:06 AM
- Marked as answer by IamaNovice Thursday, September 1, 2011 5:12 PM
Wednesday, August 31, 2011 5:06 AM -
Hi,
You need to develop a custom workflow avtivity (http://msdn.microsoft.com/en-us/library/gg309745.aspx) that will take the email entity reference as an input and then download the document from SharePoint (http://www.codeproject.com/Articles/103503/How-to-upload-download-a-document-in-SharePoint-20) and create the CRM entity record activitymineattachment (http://technet.microsoft.com/en-us/library/gg309632.aspx) using CrmService.Create method and then assosiate with email record.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Jehanzeb.Javeed Wednesday, August 31, 2011 10:31 PM
- Marked as answer by IamaNovice Thursday, September 1, 2011 4:11 PM
Wednesday, August 31, 2011 10:30 PM
All replies
-
I would say don't use the inbuilt email functionality in workflow to do that.
Create a workflow assembly pass what ever you want to this workflow assembly and send the email using crm webservices/xrm.sdk.
You can write a custom logic in this assembly.
I hope this help.
Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/- Proposed as answer by Amreek Singh Wednesday, August 31, 2011 1:35 AM
Wednesday, August 31, 2011 1:35 AM -
Hi,
Here's how you do it
1. Instantiate CRM Email object and set the mail properties from your Account record
2. Instantiate SharePointDocumentLocation (CRM SDK class) object and pass RegardingObjectId as your customEnitityId
3. Once you have the URL of your sharepoint document, use the code below to get its binary object
http://www.dotnetking.com/TechnicalComments.aspx?LogID=352
4. Once you have binary (stream or bytes) with you populate an ActivityMimeAttachment (CRM SDK) class
5. Connect 4 to 1 and your email is ready to be sent.
Manny Grewal || Australia- Proposed as answer by Manny Grewal Wednesday, August 31, 2011 5:06 AM
- Marked as answer by IamaNovice Thursday, September 1, 2011 5:12 PM
Wednesday, August 31, 2011 5:06 AM -
Thanks for these, guys. Is there any way to attach a sharepoint document in an email without writing code?Wednesday, August 31, 2011 4:31 PM
-
Hi,
You can not attach a sharepoint document in email via workflow without writing a code.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Jehanzeb.Javeed Wednesday, August 31, 2011 5:06 PM
Wednesday, August 31, 2011 5:06 PM -
Guys,
How can I invoke code from a workflow ?
Wednesday, August 31, 2011 5:47 PM -
Hi,
You need to develop a custom workflow avtivity (http://msdn.microsoft.com/en-us/library/gg309745.aspx) that will take the email entity reference as an input and then download the document from SharePoint (http://www.codeproject.com/Articles/103503/How-to-upload-download-a-document-in-SharePoint-20) and create the CRM entity record activitymineattachment (http://technet.microsoft.com/en-us/library/gg309632.aspx) using CrmService.Create method and then assosiate with email record.
Jehanzeb Javeed
http://worldofdynamics.blogspot.com
Linked-In Profile |CodePlex Profile
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".- Proposed as answer by Jehanzeb.Javeed Wednesday, August 31, 2011 10:31 PM
- Marked as answer by IamaNovice Thursday, September 1, 2011 4:11 PM
Wednesday, August 31, 2011 10:30 PM -
That's the route I am taking, thank you!Thursday, September 1, 2011 4:10 PM