locked
Send email using microsoft account RRS feed

  • Question

  • User-906199826 posted

    Hello all, I wanna send an email in my webforms app asp,net/c# using microsoft email....

    Friday, November 16, 2018 4:24 PM

Answers

  • User503812343 posted

    Try Below code

    SmtpClient smtpClient = new SmtpClient("smtp-mail.outlook.com", 587); //587
    smtpClient.UseDefaultCredentials = false;
    smtpClient.Credentials = new System.Net.NetworkCredential("<your email id>", "<password>");
    
    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpClient.EnableSsl = true;
    
    MailMessage mail = new MailMessage();
    mail.From = new MailAddress("<your email id>", "<your name>");
    mail.To.Add(new MailAddress("<to email>"));
    mail.CC.Add(new MailAddress("<cc email>"));
    smtpClient.Send(mail);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 17, 2018 3:10 AM

All replies

  • User475983607 posted

    Hello all, I wanna send an email in my webforms app asp,net/c# using microsoft email....

    Use the SmtpClient.

    https://docs.microsoft.com/en-us/dotnet/api/system.net.mail.smtpclient.-ctor?view=netframework-4.7.2

    You'll need the SMTP server, port, username, and password which you can get from your email provider.

    Friday, November 16, 2018 4:29 PM
  • User503812343 posted

    Try Below code

    SmtpClient smtpClient = new SmtpClient("smtp-mail.outlook.com", 587); //587
    smtpClient.UseDefaultCredentials = false;
    smtpClient.Credentials = new System.Net.NetworkCredential("<your email id>", "<password>");
    
    smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
    smtpClient.EnableSsl = true;
    
    MailMessage mail = new MailMessage();
    mail.From = new MailAddress("<your email id>", "<your name>");
    mail.To.Add(new MailAddress("<to email>"));
    mail.CC.Add(new MailAddress("<cc email>"));
    smtpClient.Send(mail);

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, November 17, 2018 3:10 AM