E-Mail spammed while testing an e-mail chatbot
<p>I have created a simple stock bot from the video. I have registered the bot for Skype, Facebook Messenger and E-Mail.</p>

<p>Skype, Facebook messenger works great and replies to the messages are received.</p>

<p>The problem which I have is with the E-Mail. When I send a E-Mail to the bot, for example, "Stock Price of MSFT" it sends an reply e-mail with the stock price and then it sends the same mail again and again without stopping until i remove the e-mail from the dev.botframework.com. Has anyone faced this issue. Is there any additional configuration which is needed to avoid this.</p>

<p>Eg: I sent a message to the bot e-mail saying "What is the stock price of msft" ?</p>

<p>I get a reply back with "Stock Price of msft is ... " from the bot. And the same reply e-mail I am getting continuously until I disable the E-MAIL Bot service..</p>

<p>MessageControl.cs:</p>

<pre><code>using System;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Description;
using Microsoft.Bot.Connector;
using Newtonsoft.Json;

namespace StockBot2
{
    [BotAuthentication]
    public class MessagesController : ApiController
    {
        /// &lt;summary&gt;
        /// POST: api/Messages
        /// Receive a message from a user and reply to it
        /// &lt;/summary&gt;
        public async Task&lt;HttpResponseMessage&gt; Post([FromBody]Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl));

                string StockRateString;
                StockLUIS StLUIS = await GetEntityFromLUIS(activity.Text);
                if (StLUIS.intents.Count() &gt; 0)
                {
                    switch (StLUIS.intents[0].intent)
                    {
                        case "StockPrice":
                            StockRateString = await GetStock(StLUIS.entities[0].entity);
                            break;
                        case "StockPrice2":
                            StockRateString = await GetStock(StLUIS.entities[0].entity);
                            break;
                        default:
                            StockRateString = "Sorry, I am not getting you...";
                            break;
                    }
                }
                else
                {
                    StockRateString = "Sorry, I am not getting you...";
                }

                // return our reply to the user
                Activity reply = activity.CreateReply(StockRateString);
                await connector.Conversations.ReplyToActivityAsync(reply);
            }
            else
            {
                HandleSystemMessage(activity);
            }
            var response = Request.CreateResponse(HttpStatusCode.OK);
            return response;
        }

        private Activity HandleSystemMessage(Activity message)
        {
            if (message.Type == ActivityTypes.DeleteUserData)
            {
                // Implement user deletion here
                // If we handle user deletion, return a real message
            }
            else if (message.Type == ActivityTypes.ConversationUpdate)
            {
                // Handle conversation state changes, like members being added and removed
                // Use Activity.MembersAdded and Activity.MembersRemoved and Activity.Action for info
                // Not available in all channels
            }
            else if (message.Type == ActivityTypes.ContactRelationUpdate)
            {
                // Handle add/remove from contact lists
                // Activity.From + Activity.Action represent what happened
            }
            else if (message.Type == ActivityTypes.Typing)
            {
                // Handle knowing tha the user is typing
            }
            else if (message.Type == ActivityTypes.Ping)
            {
            }

            return null;
        }

        private async Task&lt;string&gt; GetStock(string StockSymbol)
        {
            double? dblStockValue = await YahooBot.GetStockRateAsync(StockSymbol);
            if (dblStockValue == null)
            {
                return string.Format("This \"{0}\" is not an valid stock symbol", StockSymbol);
            }
            else
            {
                return string.Format("Stock Price of {0} is {1}", StockSymbol, dblStockValue);
            }
        }

        private static async Task&lt;StockLUIS&gt; GetEntityFromLUIS(string Query)
        {
            Query = Uri.EscapeDataString(Query);
            StockLUIS Data = new StockLUIS();
            using (HttpClient client = new HttpClient())
            {
                string RequestURI = "https://api.projectoxford.ai/luis/v1/application?id=1c85d9de-7c8d-4ceb-ba11-860f02ce911b&amp;subscription-key=fe48030063c6458587138c4dcd258737&amp;q=" + Query;
                HttpResponseMessage msg = await client.GetAsync(RequestURI);

                if (msg.IsSuccessStatusCode)
                {
                    var JsonDataResponse = await msg.Content.ReadAsStringAsync();
                    Data = JsonConvert.DeserializeObject&lt;StockLUIS&gt;(JsonDataResponse);
                }
            }
            return Data;
        }
    }
}
</code></pre>

<p>YahooBot.cs</p>

<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using System.Web;

namespace StockBot2
{
    public class YahooBot
    {
        public static async Task&lt;double?&gt; GetStockRateAsync(string StockSymbol)
        {
            try
            {
                string ServiceURL = $"http://finance.yahoo.com/d/quotes.csv?s={StockSymbol}&amp;f=sl1d1nd";
                string ResultInCSV;
                using (WebClient client = new WebClient())
                {
                    ResultInCSV = await client.DownloadStringTaskAsync(ServiceURL).ConfigureAwait(false);
                }
                var FirstLine = ResultInCSV.Split('\n')[0];
                var Price = FirstLine.Split(',')[1];
                if (Price != null &amp;&amp; Price.Length &gt;= 0)
                {
                    double result;
                    if (double.TryParse(Price, out result))
                    {
                        return result;
                    }
                }
                return null;
            }
            catch (WebException ex)
            {
                //handle your exception here  
                throw ex;
            }
        }
    }
}
</code></pre>