Exemplo n.º 1
0
 /// <summary>
 /// Check if initially the file with data exists.
 /// </summary>
 /// <param name="mailCredentialsIntern">the credentials to save if file does not exist</param>
 public static void CheckIfCredentialsExist(MailCredentials mailCredentialsIntern)
 {
     if (!File.Exists(Directory.GetCurrentDirectory() + FILENAME))
     {
         SaveMailCredentials(mailCredentialsIntern);
     }
 }
Exemplo n.º 2
0
 public MailCredentialsSerializable(MailCredentials mailCredentials, bool useBase64Encoding = false)
 {
     if (useBase64Encoding)
     {
         MailAddress = Convert.ToBase64String(Encoding.ASCII.GetBytes(mailCredentials.MailAddress.Address));
         DisplayName = Convert.ToBase64String(Encoding.ASCII.GetBytes(mailCredentials.MailAddress.DisplayName));
         UserName    = Convert.ToBase64String(Encoding.ASCII.GetBytes(mailCredentials.NetworkCredential.UserName));
         Password    = Convert.ToBase64String(Encoding.ASCII.GetBytes(mailCredentials.NetworkCredential.Password));
         Port        = mailCredentials.Port;
         Host        = Convert.ToBase64String(Encoding.ASCII.GetBytes(mailCredentials.Host));
     }
     else
     {
         MailAddress = mailCredentials.MailAddress.Address;
         DisplayName = mailCredentials.MailAddress.DisplayName;
         UserName    = mailCredentials.NetworkCredential.UserName;
         Password    = mailCredentials.NetworkCredential.Password;
         Port        = mailCredentials.Port;
         Host        = mailCredentials.Host;
     }
 }
Exemplo n.º 3
0
        private static void ReadMailCredentials()
        {
            MailCredentialsSerializable mailCredentialsIntern = ReadFromBinaryFile <MailCredentialsSerializable>(Directory.GetCurrentDirectory() + "\\mailCredentials.info");

            mailCredentials = new MailCredentials(mailCredentialsIntern, true);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Save the mail credentials into file
 /// </summary>
 /// <param name="mailCredentialsIntern">the mail credentials</param>
 public static void SaveMailCredentials(MailCredentials mailCredentialsIntern)
 {
     mailCredentials = mailCredentialsIntern;
     File.Delete(Directory.GetCurrentDirectory() + FILENAME);
     WriteToBinaryFile(Directory.GetCurrentDirectory() + FILENAME, new MailCredentialsSerializable(mailCredentialsIntern, true));
 }