web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Problem retrieving stream data from documents hosted in SharePoint

(0) ShareShare
ReportReport
Posted on by 5

Hello, 

I have to send an email with attached files. In fact, these attached files are documents attached to a record through DocuRef. I have already done this type of development several times without any problem, but when the document is hosted in SharePoint it does not work:

The code is this:

SysMailerMessageBuilder addPrintCerticateDocs(SysMailerMessageBuilder     _messageBuilder)

{

        DocuType            docuType;

        DocuRef             docuRef;

        System.IO.Stream    docuRefStream;

        filename            fileName;

 

       while select docuRef

            where docuRef.RefTableId    == inventBatch.TableId

            && docuRef.RefRecId              == inventBatch.RecId

        {

            docuType        = DocuType::find(docuRef.TypeId);

            if  (docuType.PrintCertificate == NoYes::Yes)

            {

                docuRefStream        = DocumentManagement::getAttachmentStream(docuRef); // Here retrieves Data stream

                if (docuRefStream.Length > 0)

                {

                   filename = ‘Not important’;

                    _messageBuilder.addAttachment(docuRefStream, filename);

                }

            }

        }

…..

The issue occurs when the DocuType associated with the DocuRef is hosted on SharePoint. In other cases it works fine.

pastedimage1665131625886v1.png

It doesn't retrieve anything in the data stream and when trying to access its content:

pastedimage1665131647084v2.png

A couple of things:

- I think, although I could be wrong, that it is not a security problem since the code has been executed by a person administrator of "everything"

- I have done the test of attaching exactly the same document, one hosted in Azure and another in SharePoint and in the first case everything is fine and in the second case, error

 

Any ideas?

Excuse my poor level of English

Thanks in advance

Carlos

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 689

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2026 Season 1

#3
Syed Haris Shah Profile Picture

Syed Haris Shah 258 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans