Beispiel #1
0
        /// <summary>
        /// Sends the specified message.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="loger">The loger.</param>
        /// <returns></returns>
        public Boolean Send(emailMessage message, ILogBuilder loger)
        {
            try
            {
                var msg = message.createMailObject();

                smtpServer.Send(msg);

                loger.log(message.address + " sent");
                return(true);
            }
            catch (Exception ex)
            {
                loger.log(message.address + " failed [" + ex.Message + "]");
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Creates message collections
        /// </summary>
        /// <param name="loger">The loger.</param>
        /// <param name="workspace">The workspace.</param>
        /// <param name="showMessage">if set to <c>true</c> [show message].</param>
        /// <returns></returns>
        public List <emailMessageCollection> createCollections(ILogBuilder loger, folderNode workspace, Boolean showMessage = true)
        {
            List <emailMessageCollection> output = new List <emailMessageCollection>();

            stringTemplate subject = new stringTemplate(subjectTemplate);

            stringTemplate content = new stringTemplate(contentTemplate);

            stringTemplate address = new stringTemplate(addressTemplate);

            emailMessageCollection messageCollection = new emailMessageCollection();

            messageCollection.name = "block01";
            output.Add(messageCollection);

            foreach (DataRow row in dataSource.Rows)
            {
                emailMessage message = new emailMessage();
                message.from    = fromAddress;
                message.content = content.applyToContent(row);
                message.subject = subject.applyToContent(row);
                message.address = address.applyToContent(row);

                if (showMessage)
                {
                    loger.AppendLine("Subject: " + message.subject);
                    loger.AppendLine("Content: " + message.content);
                }

                messageCollection.Add(message);
                if (messageCollection.Count >= collectionSize)
                {
                    messageCollection.Save(workspace.pathFor(messageCollection.name + ".xml", imbSCI.Data.enums.getWritableFileMode.overwrite, "Block of messages", true));
                    messageCollection      = new emailMessageCollection();
                    messageCollection.name = "block" + output.Count.ToString("D2");
                    output.Add(messageCollection);
                    loger.log("Message block created: " + messageCollection.name);
                }
            }

            messageCollection.Save(workspace.pathFor(messageCollection.name + ".xml", imbSCI.Data.enums.getWritableFileMode.overwrite, "Block of messages", true));

            return(output);
        }