当前位置: 首页>>代码示例>>C#>>正文


C# Message.BuildMimePartTree方法代码示例

本文整理汇总了C#中ActiveUp.Net.Mail.Message.BuildMimePartTree方法的典型用法代码示例。如果您正苦于以下问题:C# Message.BuildMimePartTree方法的具体用法?C# Message.BuildMimePartTree怎么用?C# Message.BuildMimePartTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActiveUp.Net.Mail.Message的用法示例。


在下文中一共展示了Message.BuildMimePartTree方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: _bSendMessage_Click

        private void _bSendMessage_Click(object sender, EventArgs e)
        {
            this.AddLogEntry("Creating message.");

            // We create the message object
            ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();

            // We assign the sender email
            message.From.Email = this._tbFromEmail.Text;

            // We assign the recipient email
            message.To.Add(this._tbToEmail.Text);

            // We assign the subject
            message.Subject = this._tbSubject.Text;

            // We assign the body text
            message.BodyText.Text = this._tbBodyText.Text;

            // It is required to build the mime part tree before signing
            message.BuildMimePartTree();

            if (_tbCertificate.Text != string.Empty)
            {
                CmsSigner signer = new CmsSigner(new X509Certificate2(_tbCertificate.Text));

                // Here we only want the signer's certificate to be sent along. Not the whole chain.
                signer.IncludeOption = X509IncludeOption.EndCertOnly;

                message.SmimeAttachSignatureBy(signer);
            }

            // We send the email using the specified SMTP server
            this.AddLogEntry("Sending message.");

            try
            {
                message.Send(this._tbSmtpServer.Text);

                this.AddLogEntry("Message sent successfully.");
            }

            catch (SmtpException ex)
            {
                this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }
        }
开发者ID:haoasqui,项目名称:MailSystem.NET,代码行数:52,代码来源:SendingSignedEmails.cs

示例2: sendMessageButton_Click

        private void sendMessageButton_Click(object sender, EventArgs e)
        {
            if (this.attachmentsListbox.Items.Count > 0)
            {
                this.AddLogEntry("Creating message.");

                // We create the message object
                ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();

                // We assign the sender email
                message.From.Email = this.fromEmailTextbox.Text;

                // We assign the recipient email
                message.To.Add(this.toEmailTextbox.Text);

                // We assign the subject
                message.Subject = this.subjectTextbox.Text;

                // We assign the body text
                message.BodyText.Text = this.bodyTextTextbox.Text;

                // We now add each attachments
                foreach (string attachmentPath in this.attachmentsListbox.Items)
                {
                    message.Attachments.Add(attachmentPath, false);
                }

                message.BuildMimePartTree();

                // We send the email using the specified SMTP server
                this.AddLogEntry("Sending message.");

                try
                {
                    message.Send(this.smtpServerAddressTextbox.Text);

                    this.AddLogEntry("Message sent successfully.");
                }
                catch (SmtpException ex)
                {
                    this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message));
                }
                catch (Exception ex)
                {
                    this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
                }
            }
            else
                MessageBox.Show("Please add an attachment before sending this test message.");
        }
开发者ID:JBTech,项目名称:MailSystem.NET,代码行数:50,代码来源:SendWithFileAttachments.cs

示例3: _tbSendMessage_Click

        private void _tbSendMessage_Click(object sender, EventArgs e)
        {
            this.AddLogEntry("Creating message.");

            // We create the message object
            ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();

            // We assign the sender email
            message.From.Email = this._tbFromEmail.Text;

            // We assign the recipient email
            message.To.Add(this._tbToEmail.Text);

            // We assign the subject
            message.Subject = this._tbSubject.Text;

            // We assign the body text
            message.BodyText.Text = this._tbBodyText.Text;

            // We use base 64 encoding
            message.ContentTransferEncoding = ContentTransferEncoding.Base64;   

            message.BuildMimePartTree();

            // We send the email using the specified SMTP server
            this.AddLogEntry("Sending message.");

            try
            {
                message.Send(this._tbSmtpServer.Text);

                this.AddLogEntry("Message sent successfully.");
            }

            catch (SmtpException ex)
            {
                this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }
        }
开发者ID:haoasqui,项目名称:MailSystem.NET,代码行数:44,代码来源:WorkingWithEncoding.cs

示例4: sendMessageButton_Click

        private void sendMessageButton_Click(object sender, EventArgs e)
        {
            this.AddLogEntry("Creating message.");

            // We create the message object
            ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();

            // We assign the sender email
            message.From.Email = this.fromEmailTextbox.Text;

            // We assign the recipient email
            message.To.Add(this.toEmailTextbox.Text);

            // We assign the subject
            message.Subject = this.subjectTextbox.Text;

            // We assign the body text
            message.BodyText.Text = this.bodyTextTextbox.Text;

            message.BuildMimePartTree();

            // We send the email using the specified SMTP server
            this.AddLogEntry("Sending message.");

            try
            {
                message.DirectSend();

                this.AddLogEntry("Message sent successfully.");
            }
            catch (SmtpException ex)
            {
                this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message));
            }
            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }
        }
开发者ID:JBTech,项目名称:MailSystem.NET,代码行数:39,代码来源:SendingWithoutAnSmtpServer.cs

示例5: _bSendMessage_Click

        private void _bSendMessage_Click(object sender, EventArgs e)
        {
            this.AddLogEntry("Creating message.");

            // We create the message object
            ActiveUp.Net.Mail.Message message = new ActiveUp.Net.Mail.Message();

            try
            {
                // We assign the sender email
                message.From.Email = this._tbFromEmail.Text;

                // We assign the recipient email
                message.To.Add(this._tbToEmail.Text);

                // We assign the subject
                message.Subject = this._tbSubject.Text;

                // We assign the body text
                message.BodyText.Text = this._tbBodyText.Text;

                // It is required to build the mime part tree before encrypting
                message.BuildMimePartTree();

                // Encrypt the message. You need the recipient(s) certificate(s) (with public key only).
                X509Certificate2 recipientCertificate = new X509Certificate2(_tbRecipientCertificate.Text);

                CmsRecipient recipient = new CmsRecipient(recipientCertificate);

                message.SmimeEnvelopeAndEncryptFor(recipient);

                // We send the email using the specified SMTP server
                this.AddLogEntry("Sending message.");
                           
                message.Send(this._tbSmtpServer.Text);

                this.AddLogEntry("Message sent successfully.");
            }

            catch (SmtpException ex)
            {
                this.AddLogEntry(string.Format("Smtp Error: {0}", ex.Message));
            }

            catch (Exception ex)
            {
                this.AddLogEntry(string.Format("Failed: {0}", ex.Message));
            }
        }
开发者ID:haoasqui,项目名称:MailSystem.NET,代码行数:49,代码来源:SendingCryptedEmail.cs


注:本文中的ActiveUp.Net.Mail.Message.BuildMimePartTree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。