コード例 #1
0
ファイル: TestDSN.cs プロジェクト: nagyistge/nhin-d.net35
        public void TestFailedDeliveryStatusSerialization()
        {
            Message source = this.CreateSourceMessage();

            DSN        dsnExpected = this.CreateFailedStatusNotification(3);
            DSNMessage dsnMessage  = source.CreateStatusMessage(new MailAddress(Postmaster), dsnExpected);

            Console.WriteLine(dsnMessage);
            var path = Path.GetTempFileName();

            try
            {
                dsnMessage.Save(path);
                Message loadedMessage = Message.Load(File.ReadAllText(path));
                Assert.True(loadedMessage.IsDSN());
                Assert.Equal(dsnMessage.ParsedContentType.MediaType, loadedMessage.ParsedContentType.MediaType);
                Assert.Equal(dsnMessage.SubjectValue, loadedMessage.SubjectValue);
                Assert.True(loadedMessage.HasHeader(MimeStandard.VersionHeader));
                Assert.True(loadedMessage.HasHeader(MailStandard.Headers.Date));
                Assert.True(loadedMessage.Headers.Count(x => (MimeStandard.Equals(x.Name, MimeStandard.VersionHeader))) == 1);
                var dsnActual = DSNParser.Parse(loadedMessage);

                VerifyEqual(dsnExpected, dsnActual);
            }
            finally
            {
                File.Delete(path);
            }
        }
コード例 #2
0
        /// <summary>
        /// To simplify outbound mail sending, SMTP Server allows you to drop new messages into a pickup folder
        /// You don't need to use SmtpClient or some other SMTP client
        /// </summary>
        public void SendFailure(IncomingMessage envelope, string pickupFolder, DirectAddressCollection recipients)
        {
            if (string.IsNullOrEmpty(pickupFolder))
            {
                throw new ArgumentException("value null or empty", "pickupFolder");
            }

            if (recipients.IsNullOrEmpty())
            {
                return;
            }

            if (recipients != null)
            {
                DSNMessage notification = this.ProduceFailure(envelope, recipients);

                string filePath = Path.Combine(pickupFolder, Extensions.CreateUniqueFileName());
                notification.Save(filePath);
            }


            //Or maybe
            //
            // m_router.Route(message, envelope, routedRecipients);
            //
            // This would avoid loopback encrypt/decrypt...
            //
            // ISmtpMessage message
            // MessageEnvelope envelope
            // DirectAddressCollection routedRecipients, but would use DSN in-reply-to:
            //
        }
コード例 #3
0
ファイル: LoopBackContext.cs プロジェクト: ywangmaxmd/nhin-d
 private void DropMessage(DSNMessage dsnMessage)
 {
     using (Stream stream = File.OpenWrite(
                Path.Combine(
                    Settings.PickupFolder,
                    TestFilename)))
     {
         dsnMessage.Save(stream);
     }
 }
コード例 #4
0
        /// <summary>
        /// To simplify inbound mail sending, SMTP Server allows you to drop new messages into a pickup folder
        /// You don't need to use SmtpClient or some other SMTP client
        /// </summary>
        public void SendFailure(OutgoingMessage envelope, string pickupFolder)
        {
            if (string.IsNullOrEmpty(pickupFolder))
            {
                throw new ArgumentException("value null or empty", "pickupFolder");
            }

            DirectAddressCollection recipients = envelope.RejectedRecipients;

            if (recipients.IsNullOrEmpty())
            {
                return;
            }

            if (recipients != null && envelope.UsingDeliveryStatus)
            {
                DSNMessage notification = this.ProduceFailure(envelope, recipients);


                string filePath = Path.Combine(pickupFolder, Extensions.CreateUniqueFileName());
                notification.Save(filePath);
            }
        }