#region
|
|
using System;
|
using System.IO;
|
|
#endregion
|
|
namespace CSFrameworkV5.Models
|
{
|
[Serializable]
|
public class TAttachmentBody
|
{
|
private byte[] _Content;
|
private string _FileName = "";
|
|
public byte[] Content
|
{
|
get => _Content;
|
set => _Content = value;
|
}
|
|
public string FileName
|
{
|
get => _FileName;
|
set => _FileName = value;
|
}
|
|
public void LoadFromFile(string attachedFile)
|
{
|
FileStream fs = null;
|
try
|
{
|
fs = File.OpenRead(attachedFile);
|
_Content = new byte[fs.Length];
|
_FileName = Path.GetFileName(attachedFile);
|
fs.Read(_Content, 0, _Content.Length);
|
fs.Close();
|
fs.Dispose();
|
}
|
catch
|
{
|
if (fs != null)
|
{
|
fs.Close();
|
fs.Dispose();
|
}
|
}
|
}
|
}
|
|
[Serializable]
|
public class TEmailBody
|
{
|
private TAttachmentBody[] _Attachments;
|
private string _BC = "";
|
private string _CC = "";
|
private string _Content = "";
|
private string _From = "";
|
private string _Subject = "";
|
private string _To = "";
|
private string _UserID = "";
|
|
public TAttachmentBody[] Attachments
|
{
|
get => _Attachments;
|
set => _Attachments = value;
|
}
|
|
public string BC
|
{
|
get => _BC;
|
set => _BC = value;
|
}
|
|
public string CC
|
{
|
get => _CC;
|
set => _CC = value;
|
}
|
|
public string Content
|
{
|
get => _Content;
|
set => _Content = value;
|
}
|
|
public string From
|
{
|
get => _From;
|
set => _From = value;
|
}
|
|
public string Subject
|
{
|
get => _Subject;
|
set => _Subject = value;
|
}
|
|
public string To
|
{
|
get => _To;
|
set => _To = value;
|
}
|
|
public string UserID
|
{
|
get => _UserID;
|
set => _UserID = value;
|
}
|
|
public string GetAttachmentFileNames()
|
{
|
if (_Attachments == null) return "";
|
|
var names = "";
|
foreach (var a in _Attachments) names = a.FileName + "," + names;
|
|
return names;
|
}
|
}
|
}
|