I am tasked to send a .csv file via email.
I've searched the web for possible approaches and chose this approach:
Sending email via SMTP using X++ and .NET Framework in Dynamics AX | Corbitech
the only problem I have is that I am getting the exact same error from this post in this forum:
Send email with attachment - Microsoft Dynamics AX Forum Community Forum
I have searched all possible reason for the error to happen, I made sure that the folder path is accessible, also I tried to to an UNC path for the file and made sure it has access to that path as well.
I also tried instead of using this syntax:
permissionSet = new Set(Types::Class); permissionSet.add(new InteropPermission(InteropKind::ClrInterop)); permissionSet.add(new FileIOPermission(filename, 'rw')); CodeAccessPermission::assertMultiple(permissionSet);
I used this because some articles only used this syntax:
permission = new FileIOPermission(fileName,'r'); permission.assert();
Unfortunately, everything I've researched doesn't work and the code stops at this point:
mailAttachment = new System.Net.Mail.Attachment(fileName);
Removing the line of code above, or commenting it out, it successfully sends an email. This line hinders the code to work.
There's already a lot of articles with no answer to this question, just wanted to post this again and bring it up to put an end to it.
Would like to ask for help on this. Also, is this approach still supported?
Here's the version of my AX 2012:
Kernel Version: 6.2.2000.197
Application version: 6.2.1000.1437