这是电子邮件发送的代码,但它没有给出任何结果,没有错误,在调试器中也没有警报:
public void EmailSending()
{
try
{
SmtpClient smtp = new SmtpClient("poczta.silesianet.pl", 587);
smtp.Timeout = 20000;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.UseDefaultCredentials = false;
NetworkCredential Credentials = new NetworkCredential("userName", PB_AddPassword.Password, "https://poczta.silesianet.pl/");
smtp.Credentials = Credentials;
MailMessage message = new MailMessage("from@mail","to@mail");
message.Subject = "Topic:"
message.IsBodyHtml = true;
message.Body = "Body";
IntPtr accountToken = WindowsIdentity.GetCurrent().Token;
smtp.SendAsync(message, accountToken);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
}
}
这是密码的代码,但有些东西也是错误的,因为它不记得它:
private void PB_AssPassword_TextInput(object sender, TextCompositionEventArgs e)
{
string Pass= PB_AssPassword.Password;
hasło = Environment.GetEnvironmentVariable("Pass");
if (Pass== null)
{
Environment.SetEnvironmentVariable("Pass", "Value1");
}
}
有人可以帮我吗?