EmailSettings.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using System.ComponentModel;
  2. namespace FastReport.Export.Email
  3. {
  4. /// <summary>
  5. /// Contains the email account settings such as host, email address, name.
  6. /// </summary>
  7. /// <remarks>
  8. /// You have to set up at least the <see cref="Address"/> and <see cref="Host"/> properties. If your
  9. /// host requires authentication, provide the <see cref="UserName"/> and <see cref="Password"/>
  10. /// properties as well.
  11. /// <para/>Set <see cref="UseMAPI"/> property to <b>true</b> if you want to use default email client
  12. /// such as Outlook to send an email. In this case, all other properties will be ignored.
  13. /// </remarks>
  14. [TypeConverter(typeof(FastReport.TypeConverters.FRExpandableObjectConverter))]
  15. public class EmailSettings
  16. {
  17. #region Fields
  18. private string address;
  19. private string name;
  20. private string messageTemplate;
  21. private string host;
  22. private int port;
  23. private string userName;
  24. private string password;
  25. private bool enableSSL;
  26. private bool allowUI;
  27. private bool useMAPI;
  28. #endregion
  29. #region Properties
  30. /// <summary>
  31. /// Gets or sets the sender's email address.
  32. /// </summary>
  33. /// <remarks>
  34. /// This property contains your email address (for example, "john@site.com").
  35. /// </remarks>
  36. public string Address
  37. {
  38. get { return address; }
  39. set { address = value; }
  40. }
  41. /// <summary>
  42. /// Gets or sets the sender's name.
  43. /// </summary>
  44. /// <remarks>
  45. /// This property contains your name (for example, "John Smith").
  46. /// </remarks>
  47. public string Name
  48. {
  49. get { return name; }
  50. set { name = value; }
  51. }
  52. /// <summary>
  53. /// Gets or sets the template that will be used to create a new message.
  54. /// </summary>
  55. public string MessageTemplate
  56. {
  57. get { return messageTemplate; }
  58. set { messageTemplate = value; }
  59. }
  60. /// <summary>
  61. /// Gets or sets the SMTP host name or IP address.
  62. /// </summary>
  63. public string Host
  64. {
  65. get { return host; }
  66. set { host = value; }
  67. }
  68. /// <summary>
  69. /// Gets or sets the SMTP port.
  70. /// </summary>
  71. /// <remarks>
  72. /// The default value for this property is <b>25</b>.
  73. /// </remarks>
  74. [DefaultValue(25)]
  75. public int Port
  76. {
  77. get { return port; }
  78. set { port = value; }
  79. }
  80. /// <summary>
  81. /// Gets or sets the user name.
  82. /// </summary>
  83. /// <remarks>
  84. /// Specify the <see cref="UserName"/> and <see cref="Password"/> properties if your host requires
  85. /// authentication.
  86. /// </remarks>
  87. public string UserName
  88. {
  89. get { return userName; }
  90. set { userName = value; }
  91. }
  92. /// <summary>
  93. /// Gets or sets the password.
  94. /// </summary>
  95. /// <remarks>
  96. /// Specify the <see cref="UserName"/> and <see cref="Password"/> properties if your host requires
  97. /// authentication.
  98. /// </remarks>
  99. public string Password
  100. {
  101. get { return password; }
  102. set { password = value; }
  103. }
  104. /// <summary>
  105. /// Gets or sets a value that determines whether to enable the SSL protocol.
  106. /// </summary>
  107. [DefaultValue(false)]
  108. public bool EnableSSL
  109. {
  110. get { return enableSSL; }
  111. set { enableSSL = value; }
  112. }
  113. /// <summary>
  114. /// Gets or sets a value that determines whether the account setting page
  115. /// in the "Send Email" window is enabled.
  116. /// </summary>
  117. [DefaultValue(true)]
  118. public bool AllowUI
  119. {
  120. get { return allowUI; }
  121. set { allowUI = value; }
  122. }
  123. /// <summary>
  124. /// Gets or sets a value that determines whether to use MAPI instead of SMTP when sending an email.
  125. /// </summary>
  126. [DefaultValue(false)]
  127. public bool UseMAPI
  128. {
  129. get { return useMAPI; }
  130. set { useMAPI = value; }
  131. }
  132. #endregion
  133. #region Public Methods
  134. /// <summary>
  135. /// Copies email settings from another source.
  136. /// </summary>
  137. /// <param name="source">Source to copy settings from.</param>
  138. public void Assign(EmailSettings source)
  139. {
  140. Address = source.Address;
  141. Name = source.Name;
  142. MessageTemplate = source.MessageTemplate;
  143. Host = source.Host;
  144. Port = source.Port;
  145. UserName = source.UserName;
  146. Password = source.Password;
  147. EnableSSL = source.EnableSSL;
  148. AllowUI = source.AllowUI;
  149. UseMAPI = source.UseMAPI;
  150. }
  151. #endregion
  152. /// <summary>
  153. /// Initializes a new instance of the <see cref="EmailSettings"/> class with default settings.
  154. /// </summary>
  155. public EmailSettings()
  156. {
  157. address = "";
  158. name = "";
  159. messageTemplate = "";
  160. host = "";
  161. port = 25;
  162. userName = "";
  163. password = "";
  164. allowUI = true;
  165. }
  166. }
  167. }