0

I am looking for an example of how to send an email from a botframework intent.

I have tried the code below but nothing gets sent. I am doing something wrong?

    [LuisIntent("TestEmailIntent")]
    public async Task FindFundFactSheetAsync(IDialogContext context, LuisResult result)
    {
            var emailMessage = context.MakeMessage();
            emailMessage.Recipient.Id = "myEmail@hotmail.com";
            emailMessage.Recipient.Name = "John Cleophas";
            emailMessage.Text ="Test message"

            var data = new EmailContentData();
            var channelData = Newtonsoft.Json.JsonConvert.SerializeObject(data);

            emailMessage.ChannelData = channelData;
            await context.PostAsync(emailMessage);
            context.Wait(MessageReceived);      
    }
  • Could it be that the EmailContentData object shouldn't be blank, e.g. need to add subject or message body? –  Sep 28 '16 at 07:37
  • The constructor sets the htmlbody, subject and importance. The defaults can be overridden. – John Cleophas Sep 28 '16 at 09:30
  • What is emailMessage.Recipient.Id before you assign the value to it? Does it have a value or is it null? –  Sep 28 '16 at 09:44
  • You are talking about an Email but the code is showing an IMessageActivity of the BotFramework; just to confirm: are you looking to start a new conversation with a new user from your bot? And the channel in which you are using the bot is the Email channel? – Ezequiel Jadib Sep 28 '16 at 13:34
  • The incoming message should be from any channel. The idea is that I would save some data after a sequence of prompts and then at the end I want to email the response. – John Cleophas Sep 28 '16 at 14:33
  • Sorry I just realised I am being silly. My head was stuck in bot framework .. a normal smtp client will do to send the email. the channel is irrelevant – John Cleophas Sep 28 '16 at 14:39
  • Yeap, exactly. That's why I asked my questions. – Ezequiel Jadib Sep 28 '16 at 15:13
  • Possible duplicate of [Sending E-mail using C#](https://stackoverflow.com/questions/449887/sending-e-mail-using-c-sharp) – Sam Hanley Oct 03 '17 at 19:22

1 Answers1

0

Unless your bot is employing the email channel, you will need to send the email message using your own code, not via the BotFramework. Any posts will go back to the original channel (i.e. Skype, Facebook, etc.)

Lars
  • 9,976
  • 4
  • 34
  • 40