BPM that sends sysconfig shortcut fails after upgrading to 2022.2

We have BPMs in various places that create a sysconfig shortcut file and attach it to an email. They work fine in 2021.2 but after upgrading to 2022.2 we are seeing this error when trying to compile them. Any idea how to rewrite this?

The relevant portion of the code is:

   Dictionary<string, string> attachments = new Dictionary<string, string>();
    
    attachments.Add("Shortcut.sysconfig", @"\\KineticApp\EpicorData\Shortcuts\Shortcut" + nCount + ".sysconfig");
    
    mailer.Send(message, attachments);

And the error is:
System.Drawing.Bitmap CS1503 Argument 2: cannot convert from ‘System.Collections.Generic.Dictionary<string, string>’ to ‘System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, System.IO.Stream>>’

It’s expecting something of type System.IO.Stream for the second parameter in the mailer.Send(string,System.IO.Stream) isn’t it?

1 Like

Yes I think so

I’m thinking the same as @utaylor , maybe they deprecated that method you are using. I’ve done an attachment using a dictionary<string, stream> , maybe that will still work on your version.

1 Like

yeah you can see here @aosemwengie1 that Adam has that stream object in his method input parameter.

attachments.Add("CorrectiveAction" + ttResults_Row.DMRCorAct1_ActionID.ToString() + ".sysconfig" , attachmentStream);

I don’t see you instantiating a stream object or setting up your dictionary to accept a stream object:

This is set up for strings, not string, stream from what I understand (I am a novice coder):

Dictionary<string, string> attachments = new Dictionary<string, string>();

I don’t think the @string that you are using below is a stream object either:

attachments.Add(“Shortcut.sysconfig”, @“\KineticApp\EpicorData\Shortcuts\Shortcut” + nCount + “.sysconfig”);

1 Like

Thanks for the suggestions so far, I’ll see if I can rewrite this. I really didn’t want to waste time trying to figure this out, knowing that Epicor now supports linking, but we are still using the classic screens for these objects. Sigh.

1 Like

Sorry to necropost, just wanted to post this for anyone searching later.

I tried using Dictionary<string,Stream> for my attachments as @Asz0ka and @utaylor suggested, but had trouble adding multiple attachments. I’m able to use a Dictionary<string, byte[]> and it works in Kinetic 2023.1 and Epicor 10.2.700

using ( var mailer = new Ice.Mail.SmtpMailer(this.Session) ) {


    using ( var message = new Ice.Mail.SmtpMail() ) {

        string sendFrom = (string)Db.SysCompany.Where( x => x.Company == callContextClient.CurrentCompany).FirstOrDefault().EmailFromAddr; 

        string DisplayName = "Your Display Name Here";

        if ( displayName.Length > 0 )
            sendFrom = $"{displayName} <{sendFrom}>";

        message.SetFrom(sendFrom);


        message.SetTo("recipient@email.com");
        message.SetCC( "CC@email.com; cc2@email.com" );


        message.SetSubject("Subject");
        message.SetBody("Body");
        message.IsBodyHtml = false; 

        var attachments = new Dictionary <string,byte[]>();

        attachments.Add( "fileName0.csv", System.IO.File.ReadAllBytes( @"C:\Path\To\File0.csv" ) );
        attachments.Add( "fileName1.csv", System.IO.File.ReadAllBytes( @"C:\Path\To\File1.csv" ) );


        mailer.Send( message, attachments );
    }
}
3 Likes