1

Getting no response sending mail in bot framework using smtp.

private async Task MessageReceivedAsync(IDialogContext context, IAwaitable<object> result)
{
    var activity = await result as IMessageActivity;

    try
    {
        var smtpClient = new SmtpClient
        {
            Host = "smtp-mail.outlook.com", // set your SMTP server name here
            Port = 25, // Port 
            EnableSsl = false,
            Credentials = new NetworkCredential("email@acc.com", "***")
        };


        using (var message = new MailMessage("email@acc.com", "email@acc.com")
        {
            Subject = "Hello",
            Body = " Dear "

        })
           await smtpClient.SendMailAsync(message);
    }
    catch (Exception e)
    {
        await context.PostAsync($"{e.Message}");
    }

    await context.PostAsync("generating your quote");

    context.Wait(MessageReceivedAsync);
}

I expect the code to send a mail after putting in valid email and credentials but it does not. I tried it in a console application and it did send mail. I tried implementing smtp in form flow but the code failed to proceed during execution.

slavoo
  • 5,798
  • 64
  • 37
  • 39
  • 1
    what do you mean by _"it does not"_? Some exception? – vasily.sib Jan 14 '19 at 08:59
  • I seriously doubt `smtp-mail.outlook.com` worked even in a test environment. Port 25 is the unencrypted SMTP port. No provider accepts that - even your credentials would travel as cleartext. Even intranet email servers shouldn't accept unencrypted connections. Major providers like Google and Microsoft have already moved to TLS too. You should check your provider's documentation for the correct settings. – Panagiotis Kanavos Jan 14 '19 at 09:20
  • Outlook.com's settings can be found on [POP, IMAP, and SMTP settings for Outlook.com](https://support.office.com/en-us/article/pop-imap-and-smtp-settings-for-outlook-com-d088b986-291d-42b8-9564-9c414e2aa040) – Panagiotis Kanavos Jan 14 '19 at 09:22
  • Anoterh possible snag, is that cloud providers no longer allow just anyone to connect through SMTP. They either require an API token or the email account's owner has to enable third-party SMTP access. – Panagiotis Kanavos Jan 14 '19 at 09:27

0 Answers0