private static Attachment[] CreateAttachments(MailJob mailJob) { Attachment[] attachments = new List <Attachment>().ToArray(); foreach (var maiJobAttachment in mailJob.attachments.data) { if (maiJobAttachment.contentType != MailJobContentType.None) { byte[] fileData = { };//todo:=>filerepository attachments = new Attachment[] { new Attachment(new MemoryStream(fileData), new ContentType(maiJobAttachment.contentTypeAsString) { Name = maiJobAttachment.filename }) }; } } return(attachments); }
private MailManager() { //Get the Mail Section info from config file. _mailSection = (MailSection)ConfigurationManager.GetSection("mail"); //Get whether enable mail sending. _enable = _mailSection.Enable; _enableSSL = _mailSection.EnableSSL; //Initialize the job timer ------------ _timer = new Timer(); _timer.Interval = _mailSection.Job.SendInterval * 1000 * 60; _timer.Enabled = true; _timer.Elapsed += Timer_Elapsed; //------------------------------------- //Initialize the Mail Queue ---------------- _queue = new MailQueue(_mailSection.Queue); _queue.AddingMail += Queue_AddingMail; _queue.AddedMail += Queue_AddedMail; _queue.DeletingMail += Queue_DeletingMail; _queue.DeletedMail += Queue_DeletedMail; _queue.DequeueMail += Queue_DequeueMail; _queue.ExceedQueueSize += Queue_ExceedQueueSize; _queue.MailError += QueueAndJob_MailError; //------------------------------------------ //Initialize the Mail Job ----------------- _job = new MailJob(_mailSection.Job, _queue, _enableSSL); _job.SendingMail += Job_SendingMail; _job.SendedMail += Job_SendedMail; _job.MailError += QueueAndJob_MailError; //------------------------------------------ //Initialize the Event Receiver ------- if (string.IsNullOrEmpty(_mailSection.EventReceiver) == false) { Type tp = Type.GetType(_mailSection.EventReceiver); _mailEventReceiver = (MailEvent)Activator.CreateInstance(tp, false); //------------------------------------- } }
public void SaveJob(string filename, MailJob job) { using (var stream = File.Open(filename, FileMode.Create)) MailJob.CreateSerializer().Serialize(stream, job); }