Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics GP (Archived)

sanScript run application issue

Posted on by

I am using the run application command to send automated emails for certain events within our application.  The issue I have is that it appears that the command has a maximum of 255 characters that can be sent to it.

So, if I have something like the following:

run application "c:\users\me\sendemails.exe", "-t someone@somewhere.com", "-f me@mycompany.com", "-s This is the subject", etc

The total number of characters I can pass seems to be limited to 255 characters (but not documented that I can find).  Is there any way to make this work with more than 255 characters.  The issue I have run into is that I have an email application where I need a from and to address, a subject line, a body (which is stored in a file so I have the file pathname) and the email server name.  I want to add a log file to log the emails so I can keep track of what is happening but when I add the log file and path, the total length of all parameters now exceeds 255 characters and the process fails.

Any ideas how I can get around this?

*This post is locked for comments

  • mavrick5au Profile Picture
    mavrick5au on at
    RE: sanScript run application issue

    I have resolved this problem using another method.  I created symbolic links for all of the path names and used that in my parameters.  It brought my parameter length down from 320 characters to about 240 characters which now works.

  • mavrick5au Profile Picture
    mavrick5au on at
    RE: sanScript run application issue

    Hi Mariano,

    I am attempting to implement your suggestion but cannot find the System.Diagnostics.Process library.  I have other libraries I can see, but not that one.  We are using Dex 14 if that is any help.

  • mavrick5au Profile Picture
    mavrick5au on at
    RE: sanScript run application issue

    Thanks for the replies Tim & Mariano.  I will need to give this a try.  If the Arguments variable can be defined as a text field rather than a string field, it will solve my issue.

    The sendemail client I am using is just a mail client that can be run from a command line.  It can send attachments, read a file for the body of the email (which is what I am doing as I have formatted the body as html), log the messages to a text file and send out the email via our exchange server.  The entire process runs in quiet mode which allows me to send out our invoices, quote, etc via email without user interaction.

    This is a stand alone system but is integrated into Dynamics GP via direct calls to the eConnect SPs.

  • Tim Wappat Profile Picture
    Tim Wappat 5,701 on at
    RE: sanScript run application issue

    Mark,

    Depending on exactly what your requirements are, it looks like you have options.

    regards,

    Tim.

  • Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: sanScript run application issue

    Not knowing what "special" things this email client of theirs do, I would stay away from making any other recommendations. For that matter, they could use the syEmailObj library form available in Dynamics GP if this is an integrated application.

  • Tim Wappat Profile Picture
    Tim Wappat 5,701 on at
    RE: sanScript run application issue

    Mariano,

    If you can reference .NET, could they just use the .NET SmtpClient and MailMessage classes directly then that I suspect this other .exe is just a wrapper for...?

    Tim

  • Verified answer
    Mariano Gomez Profile Picture
    Mariano Gomez 26,225 on at
    RE: sanScript run application issue

    Try this:

    using System;
    using System.Diagnostics;
    using System.ComponentModel;
    
    in string EmailFrom;
    in string EmailTo;
    in string SubjectLine;
    in string BodyFile;
    in string EmailServerName;
    in string LogFile;
    
    local Process EmailProcess;
    local ProcessStartInfo StartInfo;
    
    local text Arguments; 
    
    try
    
    	StartInfo = new ProcessStartInfo("sendemails.exe"); {may need to specify path}
    	Process.Start(StartInfo);
    
    	clear Arguments;
    	Arguments = EmailFrom + " " + EmailTo + " " + SubjectLine + " " + BodyFile + " " + EmailServerName + " " + LogFile;
    
    	StartInfo.Arguments = Arguments;
    	Process.Start(StartInfo);
    
    catch [EXCEPTION_CLASS_OBJECT_EXCEPTION]
    	{ some warning here}
    end try;


    You will need to add the System.Diagnostics.Process as a .NET Library to your Dex application.

  • Tim Wappat Profile Picture
    Tim Wappat 5,701 on at
    RE: sanScript run application issue

    CMD should let you but 1000s characters in, so I guess you are correct that this is a limit introduced by "run application".

    Could you create a powershell or batch file script that you can just pass the parameters you need to, default as much as you can of the paths in the script leaving just the file names themselves (excluding paths) to pass in.

    This will reduce the "overhead" and  keep the script name short too...

    Tim

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans