<commit_before>﻿using System.Net.Mail;
using System.Text;
using Premotion.Mansion.Core;
using Premotion.Mansion.Core.Scripting.TagScript;

namespace Premotion.Mansion.Web.Mail.ScriptTags
{
	/// <summary>
	/// Base class for all add body tags.
	/// </summary>
	public abstract class AddBodyBaseTag : ScriptTag
	{
		#region Constructors
		/// <summary>
		/// </summary>
		/// <param name="isContentHtml">Flag indicating whether the content is html or plain text.</param>
		protected AddBodyBaseTag(bool isContentHtml)
		{
			// set values
			this.isContentHtml = isContentHtml;
		}
		#endregion
		#region Overrides of ScriptTag
		/// <summary>
		/// Executes this tag.
		/// </summary>
		/// <param name="context">The application context.</param>
		protected override void DoExecute(IMansionContext context)
		{
			var webContext = context.Cast<IMansionWebContext>();

			// invoke template method
			var content = GetContent(webContext);

			// check if the body is not set already
			var message = webContext.Message;
			if (string.IsNullOrEmpty(message.Body))
			{
				// set the body
				message.Body = content;
				message.IsBodyHtml = isContentHtml;
				message.BodyEncoding = encoding;
			}
			else
			{
				// create the alternative view
				message.AlternateViews.Add(AlternateView.CreateAlternateViewFromString(content, encoding, isContentHtml ? "text/html" : "text/plain"));
			}
		}
		/// <summary>
		/// Gets the content which to add to the message.
		/// </summary>
		/// <param name="context">The <see cref="IMansionWebContext"/>.</param>
		/// <returns>Returns the content.</returns>
		protected abstract string GetContent(IMansionWebContext context);
		#endregion
		#region Private Fields
		private readonly Encoding encoding = Encoding.UTF8;
		private readonly bool isContentHtml;
		#endregion
	}
}<commit_msg>+ changed behavior of send mail tag<commit_after>﻿using System.Net.Mail;
using System.Net.Mime;
using System.Text;
using Premotion.Mansion.Core;
using Premotion.Mansion.Core.Scripting.TagScript;

namespace Premotion.Mansion.Web.Mail.ScriptTags
{
	/// <summary>
	/// Base class for all add body tags.
	/// </summary>
	public abstract class AddBodyBaseTag : ScriptTag
	{
		#region Constructors
		/// <summary>
		/// </summary>
		/// <param name="isContentHtml">Flag indicating whether the content is html or plain text.</param>
		protected AddBodyBaseTag(bool isContentHtml)
		{
			// set values
			this.isContentHtml = isContentHtml;
		}
		#endregion
		#region Overrides of ScriptTag
		/// <summary>
		/// Executes this tag.
		/// </summary>
		/// <param name="context">The application context.</param>
		protected override void DoExecute(IMansionContext context)
		{
			var webContext = context.Cast<IMansionWebContext>();

			// invoke template method
			var content = GetContent(webContext);

			// check if the body is not set already
			var message = webContext.Message;

			// create the view
			var alternateView = AlternateView.CreateAlternateViewFromString(content, encoding, isContentHtml ? MediaTypeNames.Text.Html : MediaTypeNames.Text.Plain);

			// add the alternate view to the message
			message.AlternateViews.Add(alternateView);
		}
		/// <summary>
		/// Gets the content which to add to the message.
		/// </summary>
		/// <param name="context">The <see cref="IMansionWebContext"/>.</param>
		/// <returns>Returns the content.</returns>
		protected abstract string GetContent(IMansionWebContext context);
		#endregion
		#region Private Fields
		private readonly Encoding encoding = Encoding.UTF8;
		private readonly bool isContentHtml;
		#endregion
	}
}
{'fraction_non_alphanumeric': 0.11704197942730053, 'fraction_numerical': 0.0005560189046427579, 'mean_word_length': 3.5602027883396703, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6270020', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1036, 'n_words': 291}