[.NET]Send email with smtp

Code here:

        static void SendMail3() {

            MailMessage message = new MailMessage("from@microsoft.com", "to@microsoft.com", "subject", "test body");

            message.To.Add("new@microsoft.com");

            SmtpClient client = new SmtpClient("smtphost.headquartername.corp.microsoft.com");

            client.Credentials = CredentialCache.DefaultNetworkCredentials;

            try {

                client.Send(message);

            } catch (Exception) {

                throw;

            }

        }

 

blog comments powered by Disqus