AXForum  
Вернуться   AXForum > Microsoft Dynamics CRM > Dynamics CRM: Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 03.10.2009, 15:06   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
CRMScape: MS CRM 4.0 Sending Attachments to the Browser
Источник: http://crmscape.blogspot.com/2009/10...hments-to.html
==============

In a previous blog article I covered how to take files and make them attachments to emails. Creating Attachments to emails and annotations 

Recently I’ve been spending more time building portals to MS CRM, and have needed to make attached files available to the user by browser.

From a custom web app running with MS CRM you can always create a link like the following that will call the annotation editor screen which will let you download the attachment or delete it or add an additional attachment to the annotation.

string link = String.Format(@"{0}{1}/notes/edit.aspx?id={2}", crmServerBaseUrl, orgname, thisNote.annotationid.Value);
However sometimes when working with an external application you don’t have the ability to call the MS CRM functionality or for aesthetic reasons you want things to look differently. In this case I have a Silverlight 3 application with a completely different look and feel and I just need to retrieve annotation attachments from a list associated with an entity or contact. The ExportFile() method below would work just as well with an activitymimeattachment for email attachments.

The following aspx file simply takes an annotationid querystring, retrieves that annotation ( you provide the query) and sends the attached file to the user’s browser. The user will then be able to download the file or open the file in an appropriate application.

using System;using System.Web;using Passport.Web.Services.Logic;namespace YourProject{ public partial class SendAnnotation : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["id"] != null) { Guid annotationId = new Guid(Request.QueryString["id"].Replace("{", "").Replace("}", "")); // Get annotation annotation fileContainer = // fill in the query logic you need here. // Call method to write ExportFile(fileContainer.filename, fileContainer.documentbody, fileContainer.mimetype); } } /// /// This method takes the annotation documentbody and writes it back to the browser /// with a file name and mimetype so that your browser knows how to intelligently /// handle the file being sent to it. /// /// /// /// private void ExportFile(string fileName, string content, string type) { byte[] fileContent = Convert.FromBase64String(content); Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=" + fileName); Response.ContentType = type; Response.BinaryWrite(fileContent); Response.End(); } }}



Источник: http://crmscape.blogspot.com/2009/10...hments-to.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
CRM DE LA CREME! Configuring Microsoft Dynamics CRM 4.0 for Internet-facing deployment Blog bot Dynamics CRM: Blogs 0 18.08.2009 11:05
CRMScape: MS CRM 4.0, xRM and building blocks Blog bot Dynamics CRM: Blogs 0 13.08.2009 15:05
CRMScape: RFC822 Import to MS CRM email activity utility Blog bot Dynamics CRM: Blogs 0 13.08.2009 15:05
Microsoft Dynamics CRM Team Blog: Building Rich-Client Dashboards for Microsoft Dynamics CRM with Windows Presentation Foundation Blog bot Dynamics CRM: Blogs 1 31.03.2009 13:24
Microsoft Dynamics CRM Team Blog: List Web Part for Microsoft Dynamics CRM 4.0 Deployment Scenarios Blog bot Dynamics CRM: Blogs 0 30.01.2009 22:05

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 00:05.