1

That's how I got asked a question that is this: Send mail with smtp SendAsync

I got solved but after that I got a new error like this: The SMTP host was not specified

and so are the mad again at the code that I have built.

public static void NewPassword(string mail, string name, string password)
    {
        Contract.Ensures(Contract.Result<Task>() != null);
        MailDefinition oMailDefinition = new MailDefinition();
        oMailDefinition.BodyFileName = "~/Email/emailskabelon/NewPassword.html";
        oMailDefinition.From = Email;

        Dictionary<string, string> oReplacements = new Dictionary<string, string>();
        oReplacements.Add("<<navn>>", name);
        oReplacements.Add("<<password>>", password);

        MailMessage oMailMessage = oMailDefinition.CreateMailMessage(mail, oReplacements, new LiteralControl());
        oMailMessage.Subject = NewpasswordTitle + Mail;
        oMailMessage.IsBodyHtml = true;

        SmtpClient smtp = new SmtpClient(AzureApi);
        NetworkCredential netcred = new NetworkCredential(AzureName, AzurePassword);
        smtp.UseDefaultCredentials = false;
        smtp.EnableSsl = true;

        smtp.Credentials = netcred;
        smtp.Port = Port25;
        smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
        smtp.SendMailAsync(oMailMessage);
    }

So the earlier mistake as I was at my second question it happens after I have made it on to SendMailAsync earlier, I think it just has been Send

So my question is: I have done what I asked to select the previous question but then comes a new error which I must add something to my web.config file around email and I have never had but if I do it then comes the old bug back ..

Community
  • 1
  • 1
Jasper
  • 49
  • 1
  • 9

0 Answers0