-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfiguration.cs
More file actions
81 lines (71 loc) · 2.53 KB
/
Copy pathConfiguration.cs
File metadata and controls
81 lines (71 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright © 2016-2022 ASM-SW
//asmeyers@outlook.com https://github.com/asm-sw
using System;
using System.Security;
using System.IO;
using System.Xml.Serialization;
using System.Windows;
namespace EmailWithAttachedFile
{
/// <summary>
/// This class is used to store user input between runs. The Password is not stored.
/// </summary>
[Serializable]
public class ConfigurationEmailWAF
{
public string FromEmail { get; set; }
public string SmtpServer { get; set; }
public int SmtpPort { get; set; }
public bool SmtpEnabledSSL { get; set; }
public string TemplateFileName { get; set; }
public string InputFileName { get; set; }
public string AdditionEmailAddressFileName { get; set; }
public string MailSubject { get; set; }
[XmlIgnore]
public SecureString Password {get; set;}
[XmlIgnore]
public string ConfigFileName { get; set; } // name of file containing configuration information
public ConfigurationEmailWAF()
{
string appData = Environment.GetEnvironmentVariable("APPDATA");
string dataDir = Path.Combine(appData, "DonorStatement");
if (!Directory.Exists(dataDir))
Directory.CreateDirectory(dataDir);
ConfigFileName = Path.Combine(dataDir, "ConfigurationEamilWithAttachment.xml");
}
public bool Serialize(string fileName)
{
try
{
using (TextWriter writer = new StreamWriter(fileName))
{
XmlSerializer ser = new XmlSerializer(typeof(ConfigurationEmailWAF));
ser.Serialize(writer, this);
}
}
catch (Exception ex)
{
MessageBox.Show("Error: " + ex.ToString());
}
return true;
}
public static bool DeSerialize(string fileName, ref ConfigurationEmailWAF cfg)
{
if (!File.Exists(fileName))
return true;
try
{
using (FileStream fileStream = new FileStream(fileName, FileMode.Open))
{
XmlSerializer ser = new XmlSerializer(typeof(ConfigurationEmailWAF));
cfg = (ConfigurationEmailWAF)ser.Deserialize(fileStream);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
return true;
}
}
}