Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Answered

UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

Posted on by Microsoft Employee

I want to send any type of file such as excel, text , etc in attachment when sending mail through x++ ,which i will upload in the dialog box using edt "FILENAMEOPEN"...

That means i will upload my file in dialog box , and want to send that attachment through email in x++ 

  • Abigail Profile Picture
    Abigail 550 on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    You need to use a new code to upload the file to cloud.

    Using the legacy method to upload the file would not work.

    Hence you get the error that you mentioned.

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 229,275 Most Valuable Professional on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    FilenameOpen used to be used to get a file path, which is not what you need. You want to upload the whole file.

    If simply using File::GetFileFromUser() doesn't work for you, either design a custom form or use a dialog. In either the case, the right control to use is FileUpload.

    You seem to be trying to build a dialog at runtime, therefore you need code like this:

    DialogGroup dialogGroup = dialog.addGroup("@SYS54759");
    FormBuildControl groupControl = dialog.formBuildDesign().control(dialogGroup.name());
    
    FileUploadBuild  dialogFileUpload = groupControl.addControlEx(classstr(FileUpload), 'FileUpload');
    dialogFileUpload.style(FileUploadStyle::MinimalWithFilename);
    dialogFileUpload.baseFileUploadStrategyClassName(classstr(FileUploadTemporaryStorageStrategy));

    Use Find references on FileUpload class to find concrete examples, including various ways how you can process the result.

    If you need more specific advice, you'll have to tell us what exactly you're doing (e.g. maybe you want a SysOperation dialog).

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    Hi Will,

             Still same error is coming , no resolution by that code........

             In dialog for file upload , i am using "FileOpenName" edt to upload the file , is this a problem ...........

             please some other edt if exist ?

  • WillWU Profile Picture
    WillWU 22,350 on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    Hi Udit,

    Sorry I gave you the wrong code,i have edited it, please try it again.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    Not its not working still same error,..

  • WillWU Profile Picture
    WillWU 22,350 on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    Hi Udit,

    This framework dose the job and stores your file to the temporary blob storage.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    hi will.

            how will it get my uploaded file , which i have uploaded in dialog field of mine ??

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    I am having this requirement , on dialog i have 3 fields in which on one filed i need to upload the file and send it as attachment

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    6012.Capture.PNG

  • WillWU Profile Picture
    WillWU 22,350 on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    Hi UDIT,

    Please change

    FileUploadResultBase result = File::GetFileFromUser();

    to

    FileUploadTemporaryStorageResult result =  File::GetFileFromUser() as FileUploadTemporaryStorageResult;

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,900 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,275 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans