-4
SmtpClient emailClient = new SmtpClient(MailServer);
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(sender_mail_id(organisation mail id), pwd);
emailClient.UseDefaultCredentials = false;
emailClient.Credentials = SMTPUserInfo;

emailClient.Port = 587;
emailClient.Send(msg);

上面发送邮件的代码正在工作。我想配置我自己的端口(我的 Outlook 传出服务器端口),而不是 587。如何做到这一点?(我的组织outlook id附有yahoo id)

4

1 回答 1

0

这是您可以使用的东西,例如,无论如何您都可以使用它来适应您的示例

    MailMessage mailMsg = new MailMessage();
    mailMsg.To.Add("somEmailAddress@SomMailHost.com");
    // From
    MailAddress mailAddress = new MailAddress("spongebob@sandymail.com");
    mailMsg.From = mailAddress;

    // Subject and Body
    mailMsg.Subject = "subject";
    mailMsg.Body = "body";

    // Init SmtpClient and send on port 587
    SmtpClient emailClient = new SmtpClient("mailserver", 587);
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("username", "password");
    emailClient.Credentials = credentials;
    emailClient.Send(mailMsg);
于 2013-01-15T11:20:07.180 回答