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

Community site session details

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

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

(0) ShareShare
ReportReport
Posted on by

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++ 

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,697 Most Valuable Professional on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    All right, and which part do you need our help with?

    A trivial implementation could be something like this:

    FileUploadResultBase result = File::GetFileFromUser();
    if (result.getUploadStatus())
    {
        SysMailerMessageBuilder builder = new SysMailerMessageBuilder();
        builder.addTo(...);
        builder.addAttachment(result.openResult(), result.getFileName());
    
        SysMailerFactory::sendInteractive(builder.getMessage());
    }

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

    hello Martin,

                      I am getting this error when i am selecting the file to upload

                      "The FileUpload Strategy Class you selected does not exist"??

    As well as the code is below -:

    dialogfieldfile = dialog.addField(extendedTypeStr(FilenameOpen),"File Selector");

    FileUploadResultBase result = File::GetFileFromUser();

              if (result.getUploadStatus())

              {

               builder.addTo(getvalue);

               builder.setFrom(sysEmailParameters.SMTPUserName);

               builder.addCc(cc);

               builder.addAttachment(result.openResult(), result.getFileName());

              }

  • Sohaib Cheema Profile Picture
    49,434 User Group Leader on at
    RE: UPLOADING ANY TYPE OF FILE AS ATTACHMENT IN EMAIL AND SEND THROUGH X++

    probably you would want to have a look at new way of uploading files. as the same app is used in cloud now, as well for on-prem, therefore legacy code cannot be used as in old days. please have a look at next discussion.

    community.dynamics.com/.../812848

  • WillWU Profile Picture
    22,361 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;

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

    6012.Capture.PNG

  • Community Member Profile Picture
    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
    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 ??

  • WillWU Profile Picture
    22,361 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
    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
    22,361 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.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 683 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 563 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 398 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans