Popular Posts
Enable SSL connection for Jsoup import org.jsoup.Connection; import org.jsoup.Jsoup; import javax.net.ssl.*; import java.io.IOException; import java.security.KeyManagement... Build an OpenVPN server on android device Preparation An android device, in this case, Sony xperia Z is used Root permission required Linux Deploy for deploy i... Change the AppDomain's Base Directory and Environment Directory // Update AppDomain's Base Directory string root_path = "c:\\temp\\"; AppDomain.CurrentDomain.SetData("APPBASE", roo...
Stats
SmtpClient, change authentication type of credential
using (var client = new SmtpClient())
{
    client.UseDefaultCredentials = false;
    client.Host = setting.Host;
    client.Port = setting.Port;
    client.EnableSsl = setting.EnableSsl;

    CredentialCache cache = new CredentialCache();
    // authentication type:  gssapi, ntlm, WDigest, login
    cache.Add(setting.Host, setting.Port, "login", new NetworkCredential(setting.UserName, setting.Password));
    client.Credentials = cache;

    using (var message = new MailMessage())
    {
        var body = System.IO.File.ReadAllText("content.email");

        message.From = new MailAddress(setting.Sender);
        message.ReplyToList.Add(new MailAddress(setting.Email));
        message.To.Add(new MailAddress(setting.Receiver));
        message.IsBodyHtml = true;
        message.Body = body;
        message.Subject = setting.Subject;
        message.BodyEncoding = Encoding.UTF8;
        message.SubjectEncoding = Encoding.UTF8;

        try { client.Send(message); }
        catch (Exception ex)
        {
            Log.Write(ex);
        }
    }
}