Beispiel #1
0
        // function adds mail body into HTML format, based on the following parameters:
        // * mailType:       needed to decide which template from embedded resource to use
        // * bodyParameters: the template might have variables, which are needed to be replaced from this dic
        private static string addMailBodyMsg(Common.MailType mailType, Dictionary <string, string> bodyParameters)
        {
            string embededResource        = Utils.getResourceNameFromMailType(mailType);
            string msg                    = string.Empty;
            string modifiedText           = string.Empty;
            string font                   = "calibri";
            HorizontalAlignment alignment = HorizontalAlignment.Left;

            // parse the mail body from embedded file into HTML format
            // replace all the parameter (if exist) by values from dictionary
            modifiedText = Utils.extractParameterFromDictionary(embededResource, bodyParameters);

            // determine the language to know which HTML params to set
            if (Utils.isHebrewText(modifiedText))
            {
                font      = "arial";
                alignment = HorizontalAlignment.Right;
            }

            // add into HTML line by line
            foreach (string line in modifiedText.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
            {
                msg += addHtmlLine(alignment, "black", line, 3, font);
            }

            return(msg);
        }
Beispiel #2
0
        // function return the embedded resource name based on the mail type
        // each mail type has body template saved as embedded resource
        public static string getResourceNameFromMailType(Common.MailType mailType)
        {
            switch (mailType)
            {
            case Common.MailType.Reports:
            {
                return(Anko.Properties.Resources.OrdersMail);
            }

            case Common.MailType.LoadingConfirmation:
            {
                return(Anko.Properties.Resources.LoadingConfirmationMail);
            }

            case Common.MailType.BookingConfirmation:
            {
                return(Anko.Properties.Resources.BookingConfirmationMail);
            }

            case Common.MailType.DocumentsReceipts:
            {
                return(Anko.Properties.Resources.DocumentsReceipts);
            }

            default:
                OrdersParser._Form.log("Unrecognized mail type - cannot find mail template", OrdersParser.LogLevel.Error);
                return(string.Empty);
            }
        }