private DSNMessage ReturnNoContextMessage(MimeMessage directMessage, string bodyMessage) { var to = new MailAddress(directMessage.From.Mailboxes.Single().ToString()); var perMessage = new DSNPerMessage( to.Host, directMessage.MessageId); var dsnPerRecipients = new List <DSNPerRecipient>(); foreach (var mailboxAddress in directMessage.To.Mailboxes) { var dsnPerRecipient = new DSNPerRecipient( DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent, "3.3", new MailAddress(mailboxAddress.ToString()) ); dsnPerRecipients.Add(dsnPerRecipient); } var dsn = new DSN(perMessage, dsnPerRecipients); dsn.Explanation = bodyMessage; var postMaster = new MailAddress("Postmaster@" + to.Host); var statusMessage = new DSNMessage(to.Address, postMaster.Address, dsn); return(statusMessage); }
static DSNMessage CreateNotificationMessage(Mdn mdn, TimeoutSettings settings) { var perMessage = new DSNPerMessage(settings.ProductName, mdn.MessageId); var perRecipient = new DSNPerRecipient(DSNStandard.DSNAction.Failed, DSNStandard.DSNStatus.Permanent , DSNStandard.DSNStatus.NETWORK_EXPIRED_PROCESSED, MailParser.ParseMailAddress(mdn.Recipient)); // // The nature of Mdn storage in config store does not result in a list of perRecipients // If you would rather send one DSN with muliple recipients then one could write their own Job. // var notification = new DSN(perMessage, new List <DSNPerRecipient> { perRecipient }); var sender = new MailAddress(mdn.Sender); var notificationMessage = new DSNMessage(sender.Address, new MailAddress("Postmaster@" + sender.Host).Address, notification); notificationMessage.AssignMessageID(); notificationMessage.SubjectValue = string.Format("{0}:{1}", "Rejected", mdn.SubjectValue); notificationMessage.Timestamp(); return(notificationMessage); }